I have the following data structure - list of dictionaries with movies, bucketized by genre (it's very large, here just a sample):
data={'Action': [{'title': 'They Live',
'year': 1988,
'genres': ['Action', 'Horror', 'Sci-Fi'],
'duration': 94,
'directors': ['John Carpenter'],
'actors': ['Roddy Piper', 'Keith David', 'Meg Foster'],
'rating': 7.3},
{'title': 'Ultra Warrior',
'year': 1990,
'genres': ['Action', 'Adventure', 'Sci-Fi'],
'duration': 81,
'directors': ['Augusto Tamayo San Román', 'Kevin Tent'],
'actors': ['Dack Rambo',
'Clare Beresford',
'Meshach Taylor',
'Mark Bringelson'],
'rating': 1.9},
{'title': 'Kick-As 2',
'year': 2013,
'genres': ['Action', 'Comedy', 'Crime'],
'duration': 103,
'directors': ['Jeff Wadlow'],
'actors': ['Aaron Taylor-Johnson', 'Chloë Grace Moretz'],
'rating': 6.5}],
'Drama': [{'title': 'Dirty Beautiful',
'year': 2015,
'genres': ['Comedy', 'Drama', 'Romance'],
'duration': 95,
'directors': ['Jodie Foster'],
'actors': ['Jodie Foster', 'Ricky Mabe', 'Jordan Monaghan', 'Conor Leslie', 'Darin Heames'],
'rating': 5.5},
{'title': 'Honeydripper',
'year': 2007,
'genres': ['Crime', 'Drama', 'History'],
'duration': 124,
'directors': ['John Sayles'],
'actors': ['Danny Glover', 'LisaGay Hamilton', 'Yaya DaCosta'],
'rating': 6.6}]}
I'm trying to pull a list of all movies in which 'Jodie Foster' is both an actor and director. As well as find the title of the longest movie both acted and directed by 'Clint Eastwood'?
Here's what I tried so far, but I'm a bit stuck, cause the returned list is empty... and it really shouldnt.
for i in data:
d=data[i][0]
if 'Jodie Foster' in d['directors'] and 'Jodie Foster' in d['actors']:
movies.append(d["title"])
movies
movie="None"
maximum=0
for i in data:
d=data[i][0]
if 'Clint Eastwood' in d['directors'] and 'Clint Eastwood' in d['actors']:
if d["duration"]>maximum:
maximum=d["duration"]
movie=d["title"]
Would greatly appreciate any help...