Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,152 questions

40,706 answers

573 users

How to unpack the tuple values into separate variables in Python

3 Answers

0 votes
tpl = (274, 3.14, "python")
i, f, s = tpl

print(i)      
print(f)      
print(s)     



'''
run:
 
274
3.14
python

'''

 





answered Feb 10, 2020 by avibootz
0 votes
tpl = (274, "python", "c++", "java", 3.14)

i, *s, f = tpl

print(i)      
print(s)      
print(f)     



'''
run:
 
274
['python', 'c++', 'java']
3.14

'''

 





answered Feb 10, 2020 by avibootz
0 votes
tpl = (274, "python", "c++", "java", 3.14)

c, b, *c = tpl

print(a)      
print(b)      
print(c)     



'''
run:
 
274
python
['c++', 'java', 3.14]

'''

 





answered Feb 10, 2020 by avibootz

Related questions

2 answers 113 views
1 answer 28 views
1 answer 75 views
2 answers 42 views
3 answers 38 views
...