Question: Write a program that lets the user enter a string and displays the character that appears most frequently in the string. If there is a

Write a program that lets the user enter a string and displays the character that appears most frequently in the string. If there is a tie, it must display all the letters.

The code works when there's one letter, but only displays one when there are more than one letter that has the same frequency. I need the code to show all the letters. Note: it has to be Python 3 and can't include dict () or get() , just beginner level code.

def main():

string = input('Enter a string: ')

string.lower()

count = 0 total_count = 0

most_frequent_letter = ""

for ch in string: for str in string: if str == ch: count += 1 if count > total_count: total_count = count most_frequent_letter = ch counter = 0

print("The most frequently occuring letter(s): " , most_frequent_letter)

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!