One may want to do the contrary of flattening a list of lists, like here: I was wondering how you can convert a flat list into a list of lists.
In numpy you could do something like:
>>> a=numpy.arange(9)
>>> a.reshape(3,3)
>>> a
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
I was wondering how you do the opposite, and my usual solution is something like:
>>> Mylist
['a', 'b', 'c', 'd', 'e', 'f']
>>> newList = []
for i in range(0,len(Mylist),2):
... newList.append(Mylist[i], Mylist[i+1])
>>> newList
[['a', 'b'], ['c', 'd'], ['e', 'f']]
is there a more "pythonic" way to do it?