forked from fenyx-it-academy/Class7-Python-Module-Week2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx2.py
More file actions
29 lines (16 loc) · 587 Bytes
/
Copy pathEx2.py
File metadata and controls
29 lines (16 loc) · 587 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import collections
from itertools import count
user_sentence = input("please enter your sentence: ")
user_sentence = user_sentence.lower()
my_dict = {}
dict_add = {}
for i in range(len(user_sentence)):
if user_sentence[i] ==' ':
continue
letter_count =user_sentence.count( user_sentence[i])
my_dict = { user_sentence[i] : letter_count }
dict_add.update(my_dict)
sorted_dict_add = collections.OrderedDict(sorted(dict_add.items()))
print("\nletter \t number of occurances ")
for i in sorted_dict_add:
print("{}\t{}".format(i,sorted_dict_add[i]))