SHARE
TWEET

combine2lists

huubinh49 Feb 14th, 2020 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top