Advertisement
huubinh49

combine2lists

Feb 14th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def combine(list1, list2):
  2.     listkq=[]
  3.     templ1,templ2=0,0
  4.     for i in range (len(list1)+len(list2)):
  5.         if i%2:
  6.              listkq.append(list2[templ2])
  7.              templ2+=1
  8.         else :
  9.              listkq.append(list1[templ1])
  10.              templ1+=1
  11.     return listkq
  12. listkq=combine(['a', 'b', 'c'] ,[1, 2, 3])
  13. print(listkq)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement