+ 2
Is there any way shorter than this? To swap values in more than 2 variables (mine is for 2 variables only)
4 Respostas
+ 5
in Python you can just do:
x = 1
y = 2
x, y = y, x
+ 2
thanks Ulisses Cruz it even worked for more than 2 variables
+ 2
Just a tip, search for performance tips on Python. This example Ulisses gave you is one of those tips. You may learn a lot of things reading it
0
thanks Alexander Santos it's really useful 😀