Skip to main content

Tuples

A tuple is like a list, except its size cannot change and cannot add more elements than originally specified.

The parentheses delimit a tuple. If we try to modify a tuple element, we get an error that indicates that the tuple object does not support element assignment:

tuple=(“ftp”,”ssh”,”http”,”snmp”)
tuple[0]
tuple[0]=”FTP”
Traceback (most recent call last):
    File “<stdin>”, line 1, in <module>
TypeError: ‘tuple’ object does not support item assignment

Now that you know the basic data structures for working with Python, let’s move on to learning about Python dictionaries in order to organize information in the key-value format.