Python Program to Find Highest Frequency (Most Occurring) Character in String
This Python program finds most occurring character in a given string by user.
Python Source Code: Most Occurring Character
# Finding most occuring character
# Get string from user
string = input("Enter some text: ")
# Set frequency as empty dictionary
frequency_dict = {}
for character in string:
if character in frequency_dict:
frequency_dict[character] += 1
else:
frequency_dict[character] = 1
most_occurring = max(frequency_dict, key=frequency_dict.get)
# Displaying result
print("\nMost occuring character is: ", most_occuring)
print("It is repeated %d times" %(frequency_dict[most_occurring]))
Output
Enter some text: pneumonoultramicroscopicsilicovolcanoconiosis
Most occuring character is: o
It is repeated 9 times