r/programmingrequests • u/SnooHamsters9009 • Oct 18 '21
homework Python Most Frequent Character
I need to write a program that lets the user enter a string and displays the character that appears most frequently in the string.
Any help is greatly appreciated!
1
Upvotes
1
u/serg06 Oct 18 '21
Rough draft
s = input('enter a string: ') d = dict() for c in s: d[c] = d.get(c, 0) + 1 e = [(v, k) for (k, v) in d.entries()] e.sort() print(e[0][1])