Say, I have this list:
['1', '1', '0', '1', '1', '1', '0', '0', '0', '0', '1', '0']
My expected output:
[['1', '1', '0', '1'], ['1', '1', '0', '0'], ['0', '0', '1', '0']]
I got the expected output this way:
from collections import deque as de
a = '110111000010'
a = list(a)
que = de(a)
a = []
l = []
n = 0
while que:
item = que.popleft()
l.append(item)
n += 1
if n == 4:
a.append(l)
n = 0
l = []
print(a)
I wanted to know is there a more efficient and simpler way to achieve this which can be described as elegant, understandable and most importantly pythonic.