Question
This program is about dictionaries.We want to use a dictionary to store frequency count of each letter in a string.Write Python program to do the
This program is about dictionaries.We want to use a dictionary to store frequency count of each letter in a string.Write Python program to do the following:
(a) Ask the user to enter a string.Convert all letters to uppercase.Count the frequency of each letter in the string. Store the frequency counts in a dictionary.You should count letters only.Do not count any other characters such as digits and space.Display the dictionary.
(b) Ask the user to enter a letter.Convert it to uppercase.Check whether the letter is in the dictionary.If it is not, display the message "Letter not in dictionary".Otherwise, display the frequency count of that letter, remove the letter from the dictionary and display the dictionary after that letter has been removed.
(c) Create list to store the letters that are in the dictionary.Sort and display the list.
The following is an example.
Enter a string: Magee, Mississippi
Dictionary:{'M': 2, 'A': 1, 'G': 1, 'E': 2, 'I': 4, 'S': 4, 'P': 2}
Choose a letter: s
Frequency count of that letter: 4
Dictionary after that letter removed:{'M': 2, 'A': 1, 'G': 1, 'E': 2, 'I': 4, 'P': 2}
Letters sorted: ['A', 'E', 'G', 'I', 'M', 'P']
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started