...

/

Introduction to Tuples

Introduction to Tuples

Learn how to use tuples in Python.

What is a tuple?

Though a list can store dissimilar data, it is commonly used for storing similar data.

The tuple is commonly used for storing dissimilar data. The tuple data is enclosed within () as shown below:

Press + to interact
a = ( ) # empty tuple
b = (10,) # tuple with one item. , after 10 is necessary
c = ('James', 25, 34555.50) # tuple with dissimilar items
d = (10, 20, 30, 40) # tuple with similar items
print(a)
print(b)
print(c)
print(d)

Note: In the code above, while ...