fork download
  1. # your code goes here
  2. # your code goes here
  3. def concatenate(*lists):
  4. lengths = map(len,lists)
  5. newlen = sum(lengths)
  6. newlist = [None]*newlen
  7. start = 0
  8. end = 0
  9. for l,n in zip(lists,lengths):
  10. end+=n
  11. newlist[start:end] = l
  12. start+=n
  13. return newlist
  14.  
  15. print concatenate("123","456","789")
Success #stdin #stdout 0.01s 7728KB
stdin
Standard input is empty
stdout
['1', '2', '3', '4', '5', '6', '7', '8', '9']