Answered step by step
Verified Expert Solution
Question
1 Approved Answer
advanced python dictionaries help Coding Problem 4.5.9 (Advanced) (External resource) (1.0 points possible) WordLength.py SubmitRunGrades Reset 1 #Recall last exercise that you wrote a function,
advanced python dictionaries help
Coding Problem 4.5.9 (Advanced) (External resource) (1.0 points possible) WordLength.py SubmitRunGrades Reset 1 #Recall last exercise that you wrote a function, word-lengths Console output will be displayed here 2 #which took in a string and returned dictionary Where each #word of the string was mepped to en integer value of how 4 long it Nas 5 a aThis time, write a new function called length words so that 7 athe returned dictionary maps an integer, the Tength of a 8 Ford, to a list of words from the sentence with that 9 1f a word occurs more than once, add it more than once e #hords in the list should appear in the same order in which 11 #they appeared in the 12 # 13 #For example: 15 # length-'"ords("I ate a bowl of cereal out of dog bowl today.") 17 # 5: ['today'], 2: ['of . , .of.], 4: ["boul.], 6: ['cereal.]} 18 # 19#As before, you should remove any punctuation and make the 26#string lowercase 21 a 22FH?nt: To create a new list as the value for a dictionary 24 abe able to call lengths 25 #1f ength].append word). Note that to append to the list before creating it for that #key, you'll receive 27 29 #irite your function here! 3e 31 32 33 #Below dre some lines of code tha 34 TYou can C 35 function with different inputs t will test your function the value of the variable(s) to test your 37 #1f your function works correctly, this will originally 38 print: :' 'a', 2: ['of of', 3: ['ate' out''dog'], 4: ['bowl'bowl', 5: ['today'], 6: T"cereal 41 #The keys may appear in a different order, but within each 42 #list the irds should in the order shown above 43 print(length words(I ate a bowl of cereal out of a dog bowl today.") 45 46 47 18 49Step 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