Say that the user inputs:
\"daslakndlaaaaajnjndibniaaafijdnfijdnsijfnsdinifaaaaaaaaaaafnnasm\"
How would you go about finding the highest
A lower level approach if you don't want to use regular expressions.
def count_and_reduce(s, a): num = 0 maxnum = 0 out = '' for c in s: if c == a: num += 1 maxnum = max(num, maxnum) else: num = 0 if num <= 2: out += c return maxnum, out