write a Python program to swap elements at even location with element at odd location
Answers
Answered by
8
Answer:
#program to swap element at even location with elements at odd location
val=int(input("enter the value"))
length= len(val)
print("the list is",val)
if length%2!=0:
s=s-1
for i in range(0,length,2):
print(i,i+1)
val[i], val[i+1]=val[i+1], val[i]
print(val)
Similar questions