MrSlippery icon

Mutable inside a tuple in Python

MrSlippery | PRO | 05/05/16 12:45:19 PM UTC | 0 ⭐ | 254 👁️ | Never ⏰ | []
Python |

160 B

|

None

|

0 👍

/

0 👎

p = ([1,2],9)
 
try:
    p[0].append(3)
finally:
    print p
 
try:
    p[0].extend([4])
finally:
    print p
 
try:
    p[0] += [5]
finally:
    print p

Comments