Question: Python assignment: Using function write a script that gets a sentence from the user and then uses a dictionary to summarize the number of occurrences

Python assignment:

Using function write a script that gets a sentence from the user and then uses a dictionary to summarize the number of occurrences of each letter. Ignore case, ignore blanks, and ignore punctuation. Display a two-column table of the letters (in alphabetical order) and their counts.

Example program outputs:

Give me a sentence, and I'll count the letters: A quick brown fox jumps over the lazy dog

a: 2 b: 1

c: 1 d: 1

e: 2 f: 1

g: 1 h: 1

i: 1 j: 1

k: 1 l: 1

m: 1 n: 1

o: 4 p: 1

q: 1 r: 2

s: 1 t: 1

u: 2 v: 1

w: 1 x: 1

y: 1 z: 1

Give me a sentence, and I'll count the letters: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

a: 7 b: 1

c: 4 d: 8

e: 11 g: 2

i: 11 l: 6

m: 6 n: 5

o: 10 p: 3

q: 1 r: 6

s: 6 t: 9

u: 6

(notice f, h, j, k, and v-z did not print in the second example, because they werent in the string)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!