Calculate the maximum number of consecutive repeats of a value in the list?

s = [-175, -842, -187, -66, -1, -1, -148, -17, -32, -35, 35, -1, -1, -1, -278, 278, -432, -92, -25, 549, -666, -45, -547, -38, -7, -101, -28, -43, -31, -4, 1510, -1958, -40, -25, -7, -1, -1, -1, -1, -15]
The

data example is shown above.
wants to calculate the maximum number of consecutive repeats of -1 (in the example, -1 repeats up to 4 times).
post my code (wrong):

-sharp -1 
nn = []
j = 0
for i in s:
    if i == -1:
        nn.append(j)
        j += 1
    else:
        j += 1
        continue
print(nn)

-sharp- 1 
jj = []
for i in nn:
    j = 1
    print(i)
    print(i + j)
    if s[i] == -1 and s[i + j] == -1:
        jj.append(i+j)
print(jj)
Dec.12,2021

import itertools
s = [- 175,-842,-187,-66,-1meme-1meme-148,-17,-32meme-35,35,-1meme-1meme-1meme-278278,-432 makeshift 92,-25,549,-666,-45,-547,-38,-7,-101-Yue28,-43,-31,-44,1510414.)

import itertools
s = [- 175,-842,-187,-66,-101,-148,-17,-32,-35,-1,-1-1,-278,-432,-432 -25,-7,-1,-1,-1,-1,-15]
a = [len (list (v)) for kling v in itertools.groupby (s) if kenghewashi 1]
print (the maximum number of consecutive occurrences of'- 1 is:% d'%max (a))


from collections import Counter

s = [-175, -842, -187, -66, -1, -1, -148, -17, -32, -35, 35, -1, -1, -1, -278, 278, -432, -92, -25,
     549, -666, -45, -547, -38, -7, -101, -28, -43, -31, -4, 1510, -1958, -40, -25, -7, -1, -1, -1, -1, -15]


c = Counter(s)
most = c.most_common(1)[0]
print(most[1])
Menu