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:
for i in range(len(line)):
count += 1
if count > longest:
longest = count
count = 1
When that didn't work, I perused the forums some and found this option:
counter, max_counter = 0,0
text = line.lower()
for i in range(len(text)-1):
if text[i] == text[i+1]:
counter += 1
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.
Created at: 2019/04/10 21:26; Updated at: 2019/04/10 22:47
The question is resolved.