How to find the longest repeating character of a given character in a string with Python

1 Answer

0 votes
import re

s = "hhaabbbbhhhhhhhdddefhhhgggg88"

count = len(max(re.compile("(h+h)*").findall(s)))

print(count)



'''
run:

7

'''

 



answered Sep 2, 2023 by avibootz

Related questions

...