I have the below python program to find the maximum number of repeated character and the number of times it is repeated.Since I use s[x] == s[x+1] , to compare a character with the next character , the program complains when it reaches the last index of the string for a index+1.
Please suggest me a way to fix it or a better logic to solve this problem.
s = "abcc"
x=0
count = 1
dict = {}
for x in range(0,len(s)-1):
if s[x] == s[x+1]:
count+=1
else:
dict[s[x]] = count
count=1
max_value = max(dict.values())
max_key = [k for k,v in dict.items() if v == max_value ]