In [1]:
def swap(x, y):
t = x
x = y
y = t
return x, y
In [2]:
swap(10, 20)
Out[2]:
In [3]:
def swap(x, y):
y, x = x, y
return x, y
In [4]:
swap(10, 20)
Out[4]:
It does not have to be just integers
In [5]:
swap('hello', {i: i*i for i in range(3)})
Out[5]: