Tate Taylor
When I print this code I get ‘The Help, Tate Taylor’ printed 11 times. How do I set up a code that returns both 2011 key values??
It should read Enter a year between 2005 and 2016: The Help, Tate Taylor The Artist, Michel, Hazanavicius
movie_collection_dict = {‘2005′:’Munich, Steven Spielberg’,
‘2006’:’The Prestige, Christopher Nolan’,
‘2006’:’The Departed, Martin Scorsese’,
‘2007’:’Into the Wild, Sean Penn’,
‘2008’:’The Dark Knight, Christopher Nolan’,
‘2009’:’Mary and Max, Adam Elliot’,
‘2010’:’The Kings Speech, Tom Hooper’,
‘2011’:’The Artist, Michel Hazanavicius’,
‘2011’:’The Help, Tate Taylor’,
‘2012’:’Argo, Ben Affleck’,
‘2013’:’12 Years a Slave, Steve McQueen’,
‘2014’:’Birdman, Alejandro G. Inarritu’,
‘2015’:’Spotlight, Tom McCarthy’,
‘2016’:’The BFG, Steven Spielberg’,
}
#print(movie_collection_dict)
# Build a dictionary containing the specified movie collection
for_year = True
user_input = int(input(‘Enter a year between 2005 and 2016: ‘))
while for_year:
if user_input<2005 or user_input>2016:
print(‘N/A’)
else:
for key, value in movie_collection_dict.items():
if value[1] == user_input:
print(key + ‘, ‘ + (value[1]))
for_year= False
print(movie_collection_dict[‘2011’])