4

Can somebody explain why does Python 3.6 behaves so strange in this piece of code?

a = (1, 2, [5, 6])
a[2]+=[7, 8]
print(a)

Output:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>>print(a)
(1, 2, [5, 6, 7, 8])
Chiefir
  • 2,561
  • 1
  • 27
  • 46

0 Answers0