I'm new in proggraming so don't be cruel to me :) I'm struggling with problem of the highest number of consecutive repetitions in a string. I'm given a substring for example "ABC", then I have a file with sequences of letters ex. "ABC ABC BBC CDA ABC ABC ABC DBA"(here spaces not included,used only for better look). Here output should be 3, this is the highest number of repetitions one after another.
I'm thinking of using str.count(sub[, start[, end]] method, but I have no idea how to use it in order to have valid output. I've been trying to create substring s = string[i][j] and then use s2 which is string[i+len(substring):j+len(substring)] but it seems too much cases so I gave up on it. Using code below I had valid output but only in few cases. I hope you'll help me with it. Thanks!
substr_count = 0
string = "ABCABCBBCCDAABCABCDBA"
while True:
start = 0
substring = "ABC"
loc = string.find(substring,start)
if loc == -1:
break
substr_count += 1
start = loc + len(substring)