Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Python/Count_occurence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Question :- Write a function which takes a string as input and prints total occurrences of each character.

def charOccur(s):
occurence = {}

for i in s:
if i in occurence:
occurence[i]=occurence[i]+1
else:
occurence[i]=1

return occurence

string1 = input('Enter a string:- ')
print(charOccur(string1))