Dec-09-2018, 08:44 PM
Hey guys, I'm having tons of trouble getting this to work right. So for whatever reason, not all of the years are matching correctly and I cant figure out why. Some work fine, and others don't.
MENU
Sort by:
y - Year
d - Director
t - Movie title
q - Quit
Choose an option:
12 Years a Slave:
Steve McQueen 2013
Argo:
Ben Affleck 2012
Birdman:
Alejandro G. Inarritu 2014
Into the Wild:
Sean Penn 2007
Mary and Max:
Adam Elliot 2009
Munich:
Steven Spielberg 2005
Spotlight:
Tom McCarthy 2015
The Artist:
Michel Hazanavicius 2015
The BFG:
Steven Spielberg 2016
The Dark Knight:
Christopher Nolan 2008
The Departed:
Martin Scorsese 2008
The Help:
Tate Taylor 2008
The King's Speech:
Tom Hooper 2010
The Prestige:
Christopher Nolan 2010
Notice they years for 'The Artist', 'The Departed', 'The help', and 'the Prestige' is wrong. Im stuck! Any help would be appreciated!
# Build a dictionary containing the specified movie collection names = ['Munich, Steven Spielberg', 'The Prestige, Christopher Nolan' , 'The Departed, Martin Scorsese' , 'Into the Wild, Sean Penn' , 'The Dark Knight, Christopher Nolan' , 'Mary and Max, Adam Elliot' , "The King's Speech, Tom Hooper" , 'The Artist, Michel Hazanavicius' , 'The Help, Tate Taylor' , 'Argo, Ben Affleck' , '12 Years a Slave, Steve McQueen' , 'Birdman, Alejandro G. Inarritu' ,'Spotlight, Tom McCarthy' , 'The BFG, Steven Spielberg'] movies = { 2005 : names[0], 2006 : names[1:3], 2007 : names[3], 2008 : names[4], 2009 : names[5], 2010 : names[6], 2011 : names[7:9], 2012 : names[9], 2013 : names[10], 2014 : names[11], 2015 : names[12], 2016 : names[13] } elif sel == 't': names.sort() for name in names: for key, value in movies.items(): if name == 'The Departed' or name == 'The Prestige': year = 2006 elif name == 'The Help' or name == 'The Artist': year = 2011 elif name == value: year = key temp = name.find(',') print(name[0:temp] + ':' ) print('\t' + name[temp + 2:len(name)], year) print('')This is the output i'm getting
MENU
Sort by:
y - Year
d - Director
t - Movie title
q - Quit
Choose an option:
12 Years a Slave:
Steve McQueen 2013
Argo:
Ben Affleck 2012
Birdman:
Alejandro G. Inarritu 2014
Into the Wild:
Sean Penn 2007
Mary and Max:
Adam Elliot 2009
Munich:
Steven Spielberg 2005
Spotlight:
Tom McCarthy 2015
The Artist:
Michel Hazanavicius 2015
The BFG:
Steven Spielberg 2016
The Dark Knight:
Christopher Nolan 2008
The Departed:
Martin Scorsese 2008
The Help:
Tate Taylor 2008
The King's Speech:
Tom Hooper 2010
The Prestige:
Christopher Nolan 2010
Notice they years for 'The Artist', 'The Departed', 'The help', and 'the Prestige' is wrong. Im stuck! Any help would be appreciated!