0

I have three lists

l1 = ['a', 'b', 'c']
l2 = ['1', '2', '3', '4']
l3 = ['z', 'l', 'd', 't', 'm']

I want to combine them to create

lc = [['a', '1', 'z'], ['b', '2', 'l'], ['c', '3', 'd'],
      [' ', '4', 't'], [' ', ' ', 'm']]

this question shows the roundrobin iter, but it just fills and doesn't do the blanks. I don't understand how to modify the iter to instead of removing the exhausted list but to keep on adding blanks

Community
  • 1
  • 1
cryptoref
  • 413
  • 1
  • 7
  • 17
  • `lc = list(itertools.zip_longest(l1, l2, l3, fill_value=' '))`. Prefix with `i` for Python 2. – Martijn Pieters Mar 05 '16 at 16:34
  • Was trying very hard not to duplicate the question but i just entered in the wrong search terms. This is definitely a duplicate of the others – cryptoref Mar 05 '16 at 16:43

0 Answers0