Creating and Tuple Unpacking || Tuples || Python

In this we are going to see a basic program about Creating and Tuple Unpacking in Python Programming Language.

#create a tuple
tuplex = 4, 8, 3
print(tuplex)
n1, n2, n3 = tuplex
#print first element of the tuple
print(tuplex[0])
# unpack a tuple in variables
print(n1 + n2 + n3)
# the number of variables must be equal to the number of items of the tuple
n1, n2, n3 = tuplex
# n1, n2, n3, n4 = tuplex
# above line of code gives error

# Code by Shrinivas

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post