Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- films = {
- "Finding Dory":[3,5],
- "The Meg": [18,5],
- "Tarzan":[15,2],
- "Mission Impossible":[12,4]
- }
- #this is the (dictionary) list of films we are working with. the keys are the films names and the values are for age limit and number of tickets respectively
- while True: #loop statement as in previous project
- choice = input("What film would you like to watch? ").strip().title()
- # this is first going to check if user movie choice is in dictionary if not follow indenting to bottom else statement
- # next we need to check user age so if the movie choice is in the films list it will this question...
- if choice in films:
- age = int(input("How old are you? ").strip())#input always saves as string so need to cast as integer
- if age >= films[choice][0]:
- # this will check to see if the age entered in of user is greater or equal to age limit in value of movie choice in variable films
- #next we need to check if there are enough seats
- if films[choice][1] > 0:
- print("Enjoy the film!")
- films[choice][1] = films[choice][1] - 1
- # this will check if there are tickets left (second value in dictionary for movie, and if there is it will subtract one and update the list
- # if there are tickets left are greater than zero it gives the message to enjoy the film, if not....
- else:
- print("Sorry, we are sold out!")
- else:
- print("You are to young to see that film")
- else:
- print("We don't have that film...")
Add Comment
Please, Sign In to add comment