0

Python Question How Python works in memory, if code is "a,b = b, a"

a = 1
b = 2

a, b = b, a
print(a, b)
# 2, 1

i search on internet but i don't find the solution

Jack
  • 1
  • 1
    Any time you see a comma, that's a tuple in python. Don't let the lack of parentheses distract you. In this case it's optimized out using the stack directly, but the idea is the same. – Mad Physicist Mar 24 '23 at 11:51
  • Perhaps you can read [this](https://stackoverflow.com/a/14836456/9475509). – dudung Mar 24 '23 at 11:52

0 Answers0