By simply technique i can think of, I am converting a list to 2d list, However is it possible to achievie this with higher performance either by itertools
or collections
?
n = 2
lst = ['a', 'b', 'c', 2, 'e']
for i in range(0, len(lst), n):
print lst[i:i+n]
Expected output:
[['a', 'b'], ['c', 2], ['e']]