How can I merge the two lists by 2 jumps
Question:
How can I merge the two lists in one by selecting 1st element from 1st list 2nd element from second list 2nd element…and then 3rd element from 1st list 3rd element
list 1=[a,b,c,d,e,f,] and
list 2=[g,h,i,j,k,l]
the required list is
list 3=[a,h,c,j,e,l]
in Python
I tried slicing with two loop it doesn’t work for me
Answers:
list3 = []
for i in range(0,len(list1),2):
list3.append(list1[i])
list3.append(list2[i+1])
How can I merge the two lists in one by selecting 1st element from 1st list 2nd element from second list 2nd element…and then 3rd element from 1st list 3rd element
list 1=[a,b,c,d,e,f,] and
list 2=[g,h,i,j,k,l]
the required list is
list 3=[a,h,c,j,e,l]
in Python
I tried slicing with two loop it doesn’t work for me
list3 = []
for i in range(0,len(list1),2):
list3.append(list1[i])
list3.append(list2[i+1])