I know that in Python you can swap the values of variables by doing
x,y=y,x
But I want a function that makes this swap only giving to it the variables, not having to return the values to achieve this swap. Let me be more clear with an example swapping x,y:
x,y=1,0
print(x,y) # This prints 1,0
def swapper(a,b):
#Something that swaps the variables and doesn't return anything.
swapper(x,y)
print(x,y) # This prints 0,1
Is this possible? If not, why not?
EDIT: Yes, I want to know if it's possible exactly what I wrote, not another implementation, but the function should be able to swap any two variables. You can think about this as an empty file, it won't be used for a bigger program. It's merely for learning purpose.