Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Develop a Python program that contains the following function: letter_word_count (text) The function should do the following: - letter_word_count (text) Receive a text (string) and
Develop a Python program that contains the following function:
letter_word_count (text)
The function should do the following: - letter_word_count (text) Receive a text (string) and for each letter, store the words that begin with that letter in a list. Then, for each word you find, check the first letter, if it is already in the dictionary, you will have to make an append to the existing list, and if that letter does not exist in the dictionary, add it with the first word. Important: It does not matter if the word is in lowercase or uppercase, the dictionary key is a MINUSCLE (see the test cases) and the word must remain in the original text format. The spaces are not counted.
EXAMPLE:
I affirm that I will not give or receive any unauthorized help on this exam, and that all work will be my own.
OUTPUT
{'i': ['I', 'I'], 'a': ['affirm', 'any', 'and', 'all'], 't': ['that', 'this', 'that'], 'w': ['will', 'work', 'will'], 'n': ['not'], 'g': ['give'], 'o': ['or', 'on', 'own.'], 'r': ['receive'], 'u': ['unauthorized'], 'h': ['help'], 'e': ['exam,'], 'b': ['be'], 'm': ['my']}
example2:
supercalifragilisticoespialidoso
output:
{'s': ['supercalifragilisticoespialidoso']}
EXAMPLE3:
All that is gold does not glitter, Not all those who wander are lost; The old that is strong does not wither, Deep roots are not reached by the frost.
output
{'a': ['All', 'all', 'are', 'are'], 't': ['that', 'those', 'The', 'that', 'the'], 'i': ['is', 'is'], 'g': ['gold', 'glitter,'], 'd': ['does', 'does', 'Deep'], 'n': ['not', 'Not', 'not', 'not'], 'w': ['who', 'wander', 'wither,'], 'l': ['lost;'], 'o': ['old'], 's': ['strong'], 'r': ['roots', 'reached'], 'b': ['by'], 'f': ['frost.']}
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