Introduction to Tuples
Learn how to use tuples in Python.
We'll cover the following...
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 tupleb = (10,) # tuple with one item. , after 10 is necessaryc = ('James', 25, 34555.50) # tuple with dissimilar itemsd = (10, 20, 30, 40) # tuple with similar itemsprint(a)print(b)print(c)print(d)
Note: In the code above, while ...