The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 337 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I am attaching my program. It is not working the way I need it to because I am having difficulty with working with the dictionary. I am new to programming and this lesson was one that I am struggling with. I will also attach the directions I followed for writing the program.
movies = { # create dictionary of movies, combined movie title and director into one list
"2005": ["Munich", "Steven Spielberg"],
"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", "Sam Elliot"],
"2010": ["The King's Speech", "Tom Hooper"],
"2011": [["The Artist", "Michel Hazanavicius"],["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"]
}
year_prompt = input('Enter a year between 2005 and 2016: ')
for year in movies:
if year_prompt in movies:
print('\n',movies[year_prompt])
menu = ('Menu\n'
'Sort by:\n'
'y - Year\n'
'd - Director\n'
't - Movie title\n'
'q - Quit\n')
menu_prompt = input('Choose and option:').strip().lower()
if menu_prompt == "q":
break
elif menu_prompt not in menu:
print(menu,menu_prompt)
elif menu_prompt == "y":
for year, title in movies.items():
print('%s:\n\t%s' % (year,title))
elif menu_prompt == "d":
for title, year in movies.values():
print("%s:\n%s"%(year, title))
elif menu_prompt == "t":
for title, year in movies.values():
print("%s:\n%s"%(title, year))
else:
print("N/A")
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly