-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.py
More file actions
45 lines (39 loc) · 1.38 KB
/
Copy pathproject.py
File metadata and controls
45 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
movies = []
def menu():
user_input = input("Enter 'a' to add a movie, 'l' to see your movies, 'f' to find a movie, and 'q' to quit: ")
while user_input != 'q':
if user_input == 'a':
add_movie()
elif user_input == 'l':
show_movies()
elif user_input == 'f':
find_by = input("What property of the movie is that? ")
looking_for = input("What are you looking for? ")
movie = find_movie(looking_for, lambda x: x[find_by])
print(movie or 'No movies found.')
else:
print('Unknown command-please try again.')
user_input = input("\nEnter 'a' to add a movie, 'l' to see your movies, 'f' to find a movie, and 'q' to quit: ")
def add_movie():
name = input("Enter the movie name: ")
director = input("Enter the movie director: ")
year = input("Enter the movie release year: ")
movies.append({
'name': name,
'director': director,
'year': year
})
def show_movies():
for movie in movies:
show_movie_details(movie)
def show_movie_details(movie):
print(f"Name: {movie['name']}")
print(f"Director: {movie['director']}")
print(f"Release year: {movie['year']}")
def find_movie(expected, finder):
found = []
for movie in movies:
if finder(movie) == expected:
found.append(movie)
return found
menu()