python program for swapping position of two numbers
#program to swap indexes of present to succedinng one or viceversa
list=eval(input("enter a list"))
print(list)
a=len(list)
if a%2!=0:
a=a-1
for i in range(0,a,2):
list[i],list[i+1]=list[i+1],list[i]
print("swapped position and the list is",list)
# Swap without using any temp variable
x = 66
y = 77
print("Original: ", x,y)
x = x - y
y = x + y
x = y - x
print("Swapped 1st time: ", x,y)
x = x + y
y = x - y
x = x - y
print("Swapped 2nd time: ", x,y)
# Output:
# Original: 66 77
# Swapped 1st time: 77 66
# Swapped 2nd time: 66 77