structy-logo
Pythonpython3logo
Course Contents
Layout 1
Prompt
Editor
Terminal
sign in
problem
approach
walkthrough
solution
add to favoritessettings

most frequent char

Write a function, most_frequent_char, that takes in a string as an argument. The function should return the most frequent character of the string. If there are ties, return the character that appears earlier in the string.

You can assume that the input string is non-empty.

test_00
most_frequent_char('bookeeper') # -> 'e'
test_01
most_frequent_char('david') # -> 'd'
test_02
most_frequent_char('abby') # -> 'b'
test_03
most_frequent_char('mississippi') # -> 'i'
test_04
most_frequent_char('potato') # -> 'o'
test_05
most_frequent_char('eleventennine') # -> 'e'
test_06
most_frequent_char('riverbed') # -> 'r'
terminal
settings
[guest]$ 
editor — most-frequent-char.py
reset codesettings
def most_frequent_char(s):
pass # todo
saved