Reputation: 13
how does this script works and why the variable b get 50 as its value and not 1
a = 1
b = 50
b, b = a, b
print(b)
actual result: 50
Upvotes: 1
Views: 34
Reputation: 81594
b, b = a, b
is actually a tuple assignment, and it works from left to right.
b, b = a, b
evaluates to (b, b) = (1, 50)
which in turn is executed as
b = 1
b = 50
Upvotes: 2