Answers for "compter des valeur consecutives en python"

0

compter des valeur consecutives en python

>>> from itertools import groupby
>>> def groups(l):
...     return [sum(g) for i, g in groupby(l) if i == 1]
...
>>> groups([0,1,0,0,0])
[1]
>>> groups([0,0,1,1,0])
[2]
>>> groups([1,1,0,1,1])
[2, 2]
Posted by: Guest on February-28-2021

Code answers related to "compter des valeur consecutives en python"

Python Answers by Framework

Browse Popular Code Answers by Language