![]() | ![]() |
A tuple is like a list but we cannot change elements in a tuple.
Example
Start IDLE.
Navigate to the File menu and click New Window.
Type the following:
tuple_mine = (21, 12, 31)
print(tuple_mine)
tuple_mine = (31, "Green", 4.7)
print(tuple_mine)
Accessing Python Tuple Elements
Example
Start IDLE.
Navigate to the File menu and click New Window.
Type the following:
tuple_mine=[‘t’,’r’,’o’,’g’,’r’,’a’,’m’]
print(tuple_mine[1]) #output:’r’
print(tuple_mine[3]) #output:’g’