Skip to content

Commit

Permalink
added character count python file
Browse files Browse the repository at this point in the history
This program counts the frequency of all the characters present in the message string
  • Loading branch information
Yash2rule authored Oct 8, 2020
1 parent bf05d43 commit 40fb63a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Python/char_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#character count game
import pprint
message='An apple a day keeps a doctor away'
count={}

for character in message.upper():
count.setdefault(character,0)
count[character]=count[character]+1

print(count)
#or
#pprint.pprint(count)#pprint stands for 'pretty print'
#or
#text=pprint.pformat(count)
#print(text)

0 comments on commit 40fb63a

Please sign in to comment.