This is my code (I use python 2.x):
import itertools
def grouper(input_list, n = 2):
for i in xrange(len(input_list) - (n - 1)):
yield input_list[i:i+n]
def list_of_lists(num):
nums = list(map(int,str(num)))
for first, second, third, fourth in grouper(nums, 4):
x = first, second, third, fourth
xx = list(x)
print xx
This is my input:
a = 1232331
list_of_lists(a)
This is my output:
[1, 2, 3, 2]
[2, 3, 2, 3]
[3, 2, 3, 3]
[2, 3, 3, 1]
But I want the output to be:
[[1, 2, 3, 2], [2, 3, 2, 3], [3, 2, 3, 3], [2, 3, 3, 1]]