The only hint she gave us was that we needed to make 2 lists. and it was there that she lost me.
This means that you cannot use collections.Counter , and perhaps not even dictionaries.
If we can assume that the letters are defined as the English alphabet, then one list is enough. In this case, you can create a list of 26 elements, all of which are initialized to 0. Then you can iterate over the characters of the string, and for each letter of the English alphabet, increase the counter of the n element in the list, where n is the index of the letter in the alphabet.
Create a list of 26 zeros:
counts = [0] * 26
Scroll the characters of the input string s :
for c in s:
Make sure the character is a letter:
if 'a' <= c.lower() <= 'z'
Calculate the index by a letter in the alphabet and draw a counter:
index = ord(c.lower()) - ord('a') counts[index] += 1
Once you have the counters, you can find the index that has the maximum value (left for you as an exercise), and get the corresponding character with chr(index + ord('a')) .
janos source share