Q:

Write a python program to unpack the following tuple into four variables and display each variable.

belongs to collection: Python Tuple Exercises

0

Unpack the tuple into 4 variables

Write a program to unpack the following tuple into four variables and display each variable.

Given:

tuple1 = (10, 20, 30, 40)

Expected output:

tuple1 = (10, 20, 30, 40)
# Your code
print(a) # should print 10
print(b) # should print 20
print(c) # should print 30
print(d) # should print 40

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution:

tuple1 = (10, 20, 30, 40)

# unpack tuple into 4 variables
a, b, c, d = tuple1
print(a)
print(b)
print(c)
print(d)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Swap two tuples in Python... >>
<< Create a tuple with single item 50 using python pr...