x=int(input("Enter x:"))
y=int(input("Enter y:"))
# Method 1
x,y=y,x
print(x,y)
# Method 2
t=x
x=y
y=t
print(x,y)
# Method 3
x=x+y
y=x-y
x=x-y
print(x,y)
# Method 4
x=x^y
y=x^y
x=x^y
print(x,y)
# Method 5
x=x*y
y=x/y
x=x/y
print(x,y)
a = 1
b = 2
# Swap a and b
a, b = b, a
a,b=5,6
print(a,b)
a=a+b
b=a-b
a=a-b
print(a,b)
def swap(a, b):
a = a + b
b = a - b
a = a - b
return a, b
in python below is how you swap 2 elements of list
x[i+1],x[i]=x[i],x[i+1]
Don't use function swap(user defined or pre-defined)
pos1, pos2 = 1, 3