swapping of two numbers in python

#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)

Here is what the above code is Doing:
1. First, we are taking the input from the user and storing it in a variable.
2. Then, we are finding the length of the list and storing it in a variable.
3. Then, we are checking if the length of the list is odd or even. If it is odd, we are subtracting 1 from the length of the list.
4. Then, we are using a for loop to iterate through the list.
5. In the for loop, we are swapping the elements of the list.
6. Finally, we are printing the swapped list.