Light Mode
Dark Mode
Someone explain why

Tuples are immutable types. Look at the commands below:

t = (1, 2, [3,4])
t[2] += [5,6]
t == (1, 2, [3, 4, 5, 6]) # True

When I try to perform the second action, I will catch an exception

TypeError: 'tuple' object does not support item assignment

But why the result in line 3 is True?

  • python
Created: Aug. 18, 2018, 1:56 p.m.
Updated: Aug. 22, 2018, 4:29 a.m.
0
35
User avatar
fed.kz