def consecutiveLetters(word):
currentMaxCount = 1
maxChar=""
tempCount = 1
for i in range(0, len(word) - 2):
if(word[i] == word[i+1]):
tempCount += 1
if tempCount > currentMaxCount:
currentMaxCount = tempCount
maxChar = word[i]
else:
currentMaxCount = 1
return [maxChar,tempCount]
result = consecutiveLetters("TATAAAAAAATGACA")
print("The max consecutive letter is ", result[0] , " that appears ", result[1], " times.")
This will print: The max consecutive letter is A that appears 7 times.
1
solved Finding consecutive letters in a list [closed]