I am studying list in python and I wonder how to input lists inside a list and saw this method to input multiple list inside a list:
from itertools import groupby
values = [0, 1, 2, 3, 4, 5, 351, 0, 1, 2, 3, 4, 5, 6, 750, 0, 1, 2, 3, 4, 559]
print([[0]+list(g) for k, g in groupby(values, bool) if k])
I tried to execute this in http://pythontutor.com/ to see the process step-by-step and I don't know what bool is checking if true or false before printing this output: [[0, 1, 2, 3, 4, 5, 351], [0, 1, 2, 3, 4, 5, 6, 750], [0, 1, 2, 3, 4, 559]]
link of the code above: Creating a list within a list in Python