In this exercise we will go back to the IMDB data. Feel free to reuse parts of your code from previous days!
Create a movie picker function. The function will pick the first movie that fits the user's requirements
and print its title. The user can choose to pick a movie based on one or more of the four requirements year
, genre
, minimal rating
or maximal rating
.
>>> pick_movie(genre="Drama")
The Paths of Glory
>>> pick_movie(year=2001)
Donnie Darko
>>> pick_movie(rating_min=8)
Paths of Glory
>>> pick_movie(year=2009, genre="Mystery")
The Secret in Their Eyes
Beginners: Go through the step-by-step version of this exercise. Please ask if there's someting that's unclear!
Advanced: Try to solve the exerise without looking at the hints.
Reuse parts of your old code to create a loop that goes through the imdb file and splits each row into values.
Your function must allow keyword arguments with default values. The function definition could look like this:
def pick_movie(year=None, genre=None, min_rating=None, max_rating=None):