I have a list as follows, consisting of only (-1)s and 1s:
list1=[-1,-1,1,1,1,-1,1]
I'm trying to append the number of consecutive duplicates into a list, e.g.:
count_dups=[2,3,1,1]
I've tried creating a new list and using the zip function as the first step, but can't seem to go on because of the cut-off end-value
list2=list1[1:]
empty=[]
for x,y in zip(list1,list2):
if x==y:
empty.append(x)
else:
empty.append(0)