Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Player221318ySurely if the code works synchronously the variable do not swap but end the same. For example:
a=1
b=2
a,b = b,a
Gives us:
a = b //a is now 1
b = a //b is now also 1. Where's your 2? -
And my bad. It swaps objects assigned to those variables, not the variables themself. Memory wise that is.
Related Rants
Ever felt like swapping variables?
a, b = b, a
It is the small things that count
undefined
trick
swap
variables
python