Tuples in Python are immutable, they cannot be changed. Once an element is inside a tuple (1, 2, 3), it cannot be changed.


In [1]:
t = (1,2,3)
l = [1,2,3]

In [2]:
t


Out[2]:
(1, 2, 3)

In [3]:
l


Out[3]:
[1, 2, 3]

In [4]:
len(t)


Out[4]:
3

In [7]:
#can use slicing and indexing
t[2] # indexing
t[-1] # indexing


Out[7]:
3

In [8]:
t[0:] # slicing


Out[8]:
(1, 2, 3)

In [9]:
l[2]


Out[9]:
3

In [10]:
l[1:]


Out[10]:
[2, 3]

In [11]:
l[0] = 'NEW'

In [13]:
l


Out[13]:
['NEW', 2, 3]

In [15]:
t[0] = 'NEW' #Point and case: cannot change data in a tuple.


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-995dc306a50f> in <module>()
----> 1 t[0] = 'NEW' #Point and case: cannot change data in a tuple.

TypeError: 'tuple' object does not support item assignment

In [ ]: