MENU_PROMPT = "\nEnter 'a' to add a movie, 'l' to see your movies, 'f' to find a movie by title, or 'q' to quit: "
movies = []
# And another function here for the user menu
selection = input(MENU_PROMPT)
def movie_data():
title = input("Enter the movie title: ")
director = input("Enter the movie director: ")
year = input("Enter the movie release year: ")
movies.append({
'title': title,
'director': director,
'year': year
})
def display():
print("movies =", end =" ")
for movie in movies:
print(movie['title'])
while selection != 'q':
if selection == "a":
movie_data()
elif selection == "l":
display()
elif selection == "f":
find = input("enter the movie title")
if find in movies:
print("movie found.", movies)
else:
print(f'No Such Movie, Named {find}, Found!, Try Other Movie Name.')
else:
print('Unknown command. Please try again.')
selection = input(MENU_PROMPT)
if the user inputs the f for finding the movie name in the movies dictionary then what do I write in the last elif function, can anyone explain it??
I want - (userinput movie name) - avengers output - match found! movie name - avengers, director - (what the userinputs) & year - (what the userinputs)
Aucun commentaire:
Enregistrer un commentaire