1

How this code work? How this tuple swap the values in this code?

>>> list1=[1,2,3,4]
>>> (list1[0],list1[1])=(list1[1],list1[0])
>>> 
chamathabeysinghe
  • 858
  • 2
  • 13
  • 34
  • 2
    How deep do you want to go? There's [How does swapping of members in the python tuples (a,b)=(b,a) work internally?](https://stackoverflow.com/q/21047524) – Martijn Pieters Apr 25 '15 at 16:29
  • 1
    I re-duped this to a post about swapping list elements, but [Is there a standardized method to swap two variables in Python?](https://stackoverflow.com/q/14836228) is also applicable, just not as specific. – Martijn Pieters Apr 25 '15 at 16:34

0 Answers0