I have a python list that represents cities, by integers. City 0 is HQ. For example, a possible route list would be:
[0, 7, 40, 41, 34, 96, 75, 127, 48, 65, 79, 27, 126, 78, 0,
0, 56, 45, 2, 67, 66, 124, 59, 82, 133, 102, 57, 54, 0,
0, 64, 97, 81, 87, 80, 61, 98, 52, 101, 83, 60, 109, 39, 53, 0]
This list contains three routes. How do I split these lists when they have consecutive zero's? So basically my expected output is a nested list where all the elements are seperate routes, like so:
[[0, 7, 40, 41, 34, 96, 75, 127, 48, 65, 79, 27, 126, 78, 0],
[0, 56, 45, 2, 67, 66, 124, 59, 82, 133, 102, 57, 54, 0],
[0, 64, 97, 81, 87, 80, 61, 98, 52, 101, 83, 60, 109, 39, 53, 0]]
I've tried a number of list comprehensions but I cannot seem to find the right solution...