In this Bite you learn how to lookup values from a dictionary or in Python:
You are presented with
workout_schedulewith keys: days and values: workouts. Complete
get_workout_motdthat receives a day string, title case it so the function can receive case insensitive days, look it up in the dict and do two things:
- If the day (key) is not in the dictionary, raise a
KeyError, we don't want this function to continue, the caller needs to catch this exception,
- If the key is in the dictionary, return
go_traindepending if it's a Rest day or not. The latter you will need to string-interpolate using
320 out of 327 users completed this Bite.
Will you be Pythonista #321 to crack this Bite?
It takes an average of ~40 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 2.75 on a 1-10 difficulty scale.
» You can do it! 😌