forked from fenyx-it-academy/Class4-PythonModule-Week2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoru3.py
More file actions
14 lines (12 loc) · 912 Bytes
/
soru3.py
File metadata and controls
14 lines (12 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Write a code snippet that inputs a sentence from the user, then uses a dictionary to summarize
# the number of occurrences of each letter. Ignore case, ignore blanks and assume the user does not enter
# any punctuation. # Display a two-column table of the letters and their counts with the letters in sorted order.
d = {} # Creating an empty set
sentence = input("Enter a sentence: ") # Receiving user's input
lower = sentence.lower() # Convert to the lowercase if not
print(sentence) # Print the original sentence
for i in lower: # Visit all the members
if i == " ": # Omit the spaces
continue
d[i] = lower.count(i) # Count the each different character
print(sorted(d.items())) # Print key and value couples in alphabetical order