3

I am new in Python and I need some clarity on this.

I read everywhere that tuples are immutable, so they cannot be changed, however I did this test, and I could change the values inside a list within a tuple, am I doing something wrong? Or why am I able to change this value? Thanks.

This is my test code:

>tuplelist = ('mouse',[1,2,3])
**('mouse', [1, 2, 3])**

>tuplelist[1][0]=999;
**('mouse', [999, 2, 3])**
jpp
  • 159,742
  • 34
  • 281
  • 339
YorchAMC
  • 41
  • 1
  • 4
  • Your tuple hasn't changed. It still contains a number and a **reference ** to the same list – yorodm May 12 '18 at 17:45

0 Answers0