Guest User

Untitled

a guest
Aug 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. films = {
  2. "Finding Dory":[3,5],
  3. "The Meg": [18,5],
  4. "Tarzan":[15,2],
  5. "Mission Impossible":[12,4]
  6. }
  7. #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
  8.  
  9. while True: #loop statement as in previous project
  10. choice = input("What film would you like to watch? ").strip().title()
  11. # this is first going to check if user movie choice is in dictionary if not follow indenting to bottom else statement
  12.  
  13.  
  14.  
  15. # next we need to check user age so if the movie choice is in the films list it will this question...
  16. if choice in films:
  17. age = int(input("How old are you? ").strip())#input always saves as string so need to cast as integer
  18.  
  19. if age >= films[choice][0]:
  20. # 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
  21.  
  22. #next we need to check if there are enough seats
  23.  
  24. if films[choice][1] > 0:
  25. print("Enjoy the film!")
  26. films[choice][1] = films[choice][1] - 1
  27. # 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
  28. # if there are tickets left are greater than zero it gives the message to enjoy the film, if not....
  29.  
  30. else:
  31. print("Sorry, we are sold out!")
  32. else:
  33. print("You are to young to see that film")
  34.  
  35. else:
  36. print("We don't have that film...")
Add Comment
Please, Sign In to add comment