m=eval(input("enter number")) for i in range(0,len(m),2): m[i],m[i+1]= m[i+1],m[i] print("swapped list",m) #output enter number[1,2] swapped list [2, 1]