Python Tuple

Python Tuple is used to store the sequence of immutable Python objects. \

The tuple is similar to lists since the value of the items stored in the list can be changed, 
whereas the tuple is immutable, and the value of the items stored in the tuple cannot be changed.

comma separated values with ()

we can not change tuple,
if you want to change.....
  • convert in to list
  • do manipulations
  • convert to tuple

thistuple = ("apple", "banana", "cherry", "apple", "cherry")
print(thistuple)
('apple', 'banana', 'cherry', 'apple', 'cherry')


print(len(thistuple))
5


print(type(thistuple))
<class 'tuple'>


thistuple = tuple(("apple", "banana", "cherry"))
print(thistuple)
('apple', 'banana', 'cherry')

------------------------------------------------------------------------------------------------------------------
sample example:
------------------------------------------------------------------------------------------------------------------
x,y=(10,50)
print(x)
10

print(y)
50

print("x=",x)
x= 10

print("y=",y)
y= 50