1

I have a string of gibberish, such as 'aaabbbc'. I have a list (named count_list) that keeps track of the number of times each letter in the English alphabet appears in the string. This list consists of 26 elements (all numbers).

When I use the index(max()) function on my list, only one value is returned. I need the index(max()) to find every instance of the highest value, even when the highest value is tied with another value.

maximum = count_list.index(max(count_list))
print(maximum)

I expect to see 0 1 printed, representing that the values at position 0 and 1 in the list were the largest. I see only 0. How can I search count_list for the largest value and display its position, even if there are two values that tie as the largest in count_list?

I cannot use enumerate(), and must stick to simple methods.

John Mann
  • 83
  • 1
  • 11

0 Answers0