Given a string, write a python program to find the most occurrence character and its number of occurrences.
Input : hello Output : ('l', 2) Input : geeksforgeeks Output : ('e', 4)
We can solve this problem quickly in python using Counter() method. Simple Approach is to
1) Create a dictionary using Counter method having strings as keys and their frequencies as values.
2) Find the maximum occurrence of a character i.e. value and get the index of it.
- Python Program to Find the Number Occurring Odd Number of Times
- Python program to search for the minimum element occurring consecutively n times in a matrix
- Python - Remove all duplicate occurring tuple records
- Python - Maximum occurring Substring from list
- Python - Characters occurring in multiple Strings
- Kth most frequent Character in a given String
- Python | Substitute character with its occurrence
- Python | Insert character after every character pair
- Python program to Count Uppercase, Lowercase, special character and numeric values using Regex
- Python program to find occurrence to each character in given string
- Python program to find the character position of Kth word from a list of strings
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python program to divide dictionary and its keys into K equal dictionaries
- Python | Find most common element in each column in a 2D list
- Python | Find most frequent element in a list
- Python | Find most common element in a 2D list
- Python program to print Rows where all its Elements' frequency is greater than K
- Python program for removing i-th character from a string
- Python Regex | Program to accept string ending with alphanumeric character
- Python program to Replace all Characters of a List Except the given character
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.