''' DS2000 Spring 2020 Source code from class - calling an API function The dictionary returned from get_genres is identical to the dictionary returned in the previous example from class where we read a JSON file. Same data, same format... different source. ''' import requests # Your API key would go here! API_KEY = '' def get_genres(api_key): ''' Function: get_genres Parameters: api key (string) Return: dictionary of genres ''' http_params = {'api_key':api_key, 'language':'eng-US'} response = requests.get('https://api.themoviedb.org/3/genre/movie/list', http_params) return response.json() def main(): genres = get_genres(API_KEY) # Print each genre by itself lod = genres['genres'] for d in lod: print(d['name']) main()