Sep-04-2023, 06:19 PM
I am trying to make an application that in part prints out the last 10 films released based on actor which means i want to exclude announced films if they haven/t been released yet
def get_data_actor_name(id): global movie_name,cg search = cg.get_person(id) filmography=cg.get_person_filmography(id) last_ten_films=filmography['data']['filmography']['actor'] for movie in last_ten_films: if bool(movie['year']): movie_name.append(movie['title'], movie['year']) messagebox.showinfo(title=f"{search}'s latest film information", message=f"{movie_name}") movie_name.clear()the code above returns a KeyError (year) as you can see below
Error:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\giorg\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "C:\Users\giorg\PycharmProjects\pythonProject2\IMDB\main.py", line 65, in search_for_info
check_answer(search)
File "C:\Users\giorg\PycharmProjects\pythonProject2\IMDB\main.py", line 38, in check_answer
get_data_actor_name(id)
File "C:\Users\giorg\PycharmProjects\pythonProject2\IMDB\main.py", line 21, in get_data_actor_name
if bool(movie['year']):
File "C:\Users\giorg\AppData\Local\Programs\Python\Python39\lib\site-packages\imdb\utils.py", line 1503, in __getitem__
rawData = self.data[key]
KeyError: 'year'