Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- year:
- title, director
- title:
- director, year
- director:
- title, year
- movie_dict = {
- '2015': [['Splotlight', 'Tom MacCarthy'], ['Timbuktu', 'Abderrahmane Sissako']],
- '2005': [['Munich', 'Steven Spielberg'],
- ['Star Wars: Episode III - Revenge of the Sith', 'George Lucas'],
- ['Batman Begins', 'Christopher Nolan']],
- '2006': [['The Prestige', 'Christopher Nolan'],
- ['The Departed', 'Martin Scorsese']],
- '2007': [['Into the Wild', 'Sean Penn']],
- '2008': [['The Dark Knight', 'Christopher Nolan']],
- '2009': [['Mary and Max', 'Adam Elliot']],
- '2010': [['The King's Speech', 'Tom Hooper']],
- '2011': [['The Artist', 'Michel Hazanaviscius'], ['The Help', 'Tate Taylor']],
- '2012': [['Argo', 'Ben Afflect']],
- '2013': [['12 Years a Slave', 'Steve McQueen']],
- '2014': [['Birdman', 'Alejandro G. Inarritu']],
- '2016': [['The BFG', 'Steven Spielberg']],
- }
- # sort by year, sort by Title if multiple movies within a year
- print('Movies by Year')
- for year, movie_list in sorted(movie_dict.items(), key=lambda year: year[0]):
- print(year + ': ')
- for title, director in sorted(movie_list, key=lambda x: x[0]):
- print('t' + title + ', ' + director)
- title_dict = {movie[0]: (movie[1], year)
- for year, movies in movie_dict.items()
- for movie in movies}
- # sort by title
- print('nnMovies by title')
- for title, movie in sorted(title_dict.items(), key=lambda title: title[0]):
- print(title + ': ')
- print('t' + movie[0] + ', ' + movie[1])
- director_dict = {}
- for year, movie_list in movie_dict.items():
- for title, director in movie_list:
- if director not in director_dict:
- director_dict[director] = []
- director_dict[director].append([title, year])
- # sort by director, if multiple title then sort by year
- for director, movie_list in sorted(director_dict.items(), key=lambda x: x[0]):
- print(director + ': ')
- for title, year in sorted(movie_list, key=lambda x: x[1]):
- print('t' + title + ', ' + year)
- Movies by Year
- 2005:
- Batman Begins, Christopher Nolan
- Munich, Steven Spielberg
- Star Wars: Episode III - Revenge of the Sith, George Lucas
- 2006:
- The Departed, Martin Scorsese
- The Prestige, Christopher Nolan
- Movies by title
- 12 Years a Slave:
- Steve McQueen, 2013
- Argo:
- Ben Afflect, 2012
- Batman Begins:
- Christopher Nolan, 2005
- Birdman:
- Alejandro G. Inarritu, 2014
- Ben Afflect:
- Argo, 2012
- Christopher Nolan:
- Batman Begins, 2005
- The Prestige, 2006
- The Dark Knight, 2008
Add Comment
Please, Sign In to add comment