tuple in python and two elements swap program

 tuple in python and two elements swap program



mytuple=(10,20,30) #tuple is defined like this
print(mytuple)
#mytuple[1]=5 #this generates an error( TypeError: 'tuple' object does not support item assignment)

#program to swap values in two numbers
a=10
b=20
print(a,b)
a,b=b,a #swapping the values
print(a,b)

Comments