Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

list element swapping python

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]
 
PREVIOUS NEXT
Tagged: #list #element #swapping #python
ADD COMMENT
Topic
Name
2+6 =