Programming Examples

Python program to swap list elements with even and locations

write a program to input a list of numbers and swap elements at the even location with the elements at the odd location.


val=eval(input("Enter a list "))
print("Original List is:",val)
if s%2!=0:
for i in range(0,s,2):
print("List after swapping :",val)

Enter a list [3,4,5,6]

Original List is: [3, 4, 5, 6]

List after swapping : [4, 3, 6, 5]

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz