for example I have the following list:
contents= [\"i have two pens\",\"prices = 5$\",\"made in ____ and ____\"]
I want to split them such a wa
A quick demo to expand on my comment, using izip_longest from itertools:
>>> from itertools import izip_longest
>>> contents = ["i have two pens",
"prices = 5$",
"made in ____ and ____"]
>>> array = [phrase.split() for phrase in contents]
>>> for t in izip_longest(*array, fillvalue=" "):
print t
('i', 'prices', 'made')
('have', '=', 'in')
('two', '5$', '____')
('pens', ' ', 'and')
(' ', ' ', '____')
You don't need to modify array
, this pads for you as you iterate over the sublists.