Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

count consecutive values in python

#count consecutif 1 in list. list exemple l=['1','1','0','1','0','1,'1',1']
cpt=0
    compte=[]
    for i in ch:
        if i=='1':
            cpt +=1
        else:
            compte.append(cpt)
            cpt=0
    compte.append(cpt)
 
PREVIOUS NEXT
Tagged: #count #consecutive #values #python
ADD COMMENT
Topic
Name
1+9 =