In Fluent Python, By Luciano Ramalho, Chapter 8, Copies Are Shallow by Default, there is an example:
>>> listOne = [3, [55, 44], (7, 8, 9)]>>> listTwo = list(listOne)>>> listTwo[3, [55, 44], (7, 8, 9)]>>> listTwo == listOneTrue>>> listTwo is listOneFalse
The author suggests that we should run through this code using Online Python Tutor to see what is happening step by step.
I executed the first two lines using Online Python Tutor, and this is the screen shot I got:
What confuses me is:
All three elements from the each list, the immutable integer, the list and the tuple are actually the same, e.g.
listOne[0] is listTwo[0] #TruelistOne[1] is listTwo[1] #TruelistOne[2] is listTwo[2] #True
So why the graph shows two separate 3s at the beginning of their respective list?