📜  用于交换两个数字位置的python程序 - Python代码示例

📅  最后修改于: 2022-03-11 14:47:15.232000             🧑  作者: Mango

代码示例1
#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)