8
How can I reverse the value of a
for b
and b
for a
without using another variable?
For example, a
worthwhile 1
becomes real b
worthwhile 3
and b
becomes real a
that was worth 1
.
#antes de inverter
a = 1
b = 3
#depois de inverter
a = 3
b = 1
I opened the question Multiple assignment in Python uses tuples? to discuss the internal workings behind this multiple assignment.
– Woss
This does what I want, but if I’m not mistaken the tuple that will be unpacked will create a new variable
– Nium
@Nium Does exactly what you need, has more details on the link of the first comment.
– Woss