swap two numbers using 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: python swap two variables
# Python shorthand for swapping
x,y=5,2
print(x,y)
x,y=y,x
print(x,y)