swap four variables python code example
Example 1: python swap numbers
x, y = 10, 20
print(x, y) # 10 20
x, y = y, x
print(x, y) # 20 10
Example 2: swapping variables in python
a = 1
b = 2
a, b = b, a
# a = 2 , b = 1
x, y = 10, 20
print(x, y) # 10 20
x, y = y, x
print(x, y) # 20 10
a = 1
b = 2
a, b = b, a
# a = 2 , b = 1