Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Define the function getValidMoviesData that: accepts a list of movie titles Uses the getMoviesData function to return a list of valid movie dictionaries. This
Define the function getValidMoviesData that: accepts a list of movie titles Uses the getMoviesData function to return a list of valid movie dictionaries. This function needs to test the return value from getMovies Data to filter out any False return values. def getValidMovies Data (movieTitles): return None # Run this cell to test the function for movie in getValid MoviesData(["Superbabies: Baby Geniuses 2", "The Shawshank Redemption", "Foobarbat", "asdfasdfasdfasdfasdf" "Thor"]): print (movie [ 'Title'], movie [ 'Year']) 3 def getOMDBData(title, apikey): url = 'https://www.omdbapi.com/' params = {'t': title, 'apikey': apikey} try: response = requests.get(url, params-params) data response.json () if data[ 'Response'] == 'False': return false return data except: return False def getMoviesData (movieTitles): apikey= 'apikey' movies = [] for title in movieTitles: movie_data = getOMDBData (title, apikey) if movie_data: movies.append(movie_data) return movies
Step by Step Solution
There are 3 Steps involved in it
Step: 1
You can define the getValidMoviesData function as follows import requests def getOMDBDatatitle apike...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