Swap to exchange first-half element of list with second-half elements assuming list is having even number of elements.
Answers
Answered by
1
Answer:
Explanation:
# define a list
list = [10, 20, 30, 40, 50, 60]
# Create list1 with half elements (first 3 elements)
list1 = list [:3]
# Create list2 with next half elements (next 3 elements)
list2 = list [3:]
# print list (s)
print "list : ",list
print "list1: ",list1
print "list2: ",list2
Similar questions