Identify runs in list

skorpio11 at gmail.com skorpio11 at gmail.com
Sun Oct 4 04:21:49 CEST 2009


Hi all,

I have a data structure in a list as in: [0 0 0 3 0 5 0 0 0 0 1 0 4 0
5 0 0 7 0 0 0 0 0 12 0 0 4]

I would like to extract three list from this data:

1) runsOfZero: [3 4 5]
2) runsOfNonZero: [3 8 4]
3) SumOfRunsOfNonZero: [8 17 16]

Any suggestions would be appreciated



More information about the Python-list mailing list