I've tried a couple of times to solve the Long Repeat mission, but despite my codes passing the Run test, they don't pass the Check.
To return the length of the longest substring of the same character:
def long_repeat(line): longest,count=0,1 for i in range(len(line)): try: if line[i]==line[i+1]: count += 1 if count > longest: longest = count else: count = 1 except IndexError: return longest return longest
When that didn't work, I perused the forums some and found this option:
def long_repeat(line): counter, max_counter = 0,0 text = line.lower() for i in range(len(text)-1): if text[i] == text[i+1]: counter += 1 else: max_counter = max(max_counter, counter+1) counter = 0 return len(text) and max(max_counter, counter)
Which still wound up with the same problem. Both options appear to work fine, but fail the Check.
The question is resolved.