I have this code:
binary = '011010'
binary = list(map(''.join, zip(*[iter(binary)]*3)))
b=[]
for h in range(len(binary)):
for i in range(len(binary[h])-1):
c = binary[h][i:i+2]
b.append(c)
where i get the result:
binary = ['011', '010']
b = ['01', '11', '01', '10']
And I would like to get an effect:
b = [['01', '11'], ['01', '10']]
So I would like to first take binary[0] and make a loop and then next binary[1] and add the results to list 'b', but in separate sub-lists. While in the above code, it saves the results one by one in the list 'b'.
How can this be done? Ideally, sub-lists should be creating in the loop.