Skip to content

Commit 525b0dd

Browse files
authored
Merge pull request #67 from Vava145/patch-4
Create mostoccuring.py
2 parents 15baea6 + 5fbaba9 commit 525b0dd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

python/mostoccuring.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Python program to find the most occurring
2+
# character and its count
3+
from collections import Counter
4+
5+
def find_most_occ_char(input):
6+
7+
# now create dictionary using counter method
8+
# which will have strings as key and their
9+
# frequencies as value
10+
wc = Counter(input)
11+
12+
# Finding maximum occurrence of a character
13+
# and get the index of it.
14+
s = max(wc.values())
15+
i = wc.values().index(s)
16+
17+
print wc.items()[i]
18+
19+
# Driver program
20+
if __name__ == "__main__":
21+
input = 'geeksforgeeks'
22+
find_most_occ_char(input)

0 commit comments

Comments
 (0)