We've moved away from repl.it for coding exercises. Check out the new exercises on Coding Rooms with automated submissions.
Login to your Udemy course and head over to lesson 9 to get the sign up link: Click here
You are going to use Dictionary Comprehension to create a dictionary called result
that takes each word in the given sentence and calculates the number of letters in each word.
Try Googling to find out how to convert a sentence into a list of words.
Do NOT Create a dictionary directly. Try to use Dictionary Comprehension instead of a Loop.
{
'What': 4,
'is': 2,
'the': 3,
'Airspeed': 8,
'Velocity': 8,
'of': 2,
'an': 2,
'Unladen': 7,
'Swallow?': 8
}
-
Use the keyword method for starting the Dictionary comprehension and fill in the relevant parts.
-
You can get a list of the words in a string by using the .split() method: https://www.w3schools.com/python/ref_string_split.asp
Before checking the solution, try copy-pasting your code into this repl:
https://repl.it/@appbrewery/day-26-4-test-your-code
This repl includes my testing code that will check if your code meets this assignment's objectives.