Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. #Program name: Maggie_Potts_A5.py
  2. #Movie List Maintenance
  3. #Author: Maggie Potts
  4.  
  5.  
  6.  
  7. movies = [[1939, 'Gone with the Wind', 'drama'],
  8. [1943, 'Casablanca', 'drama'],
  9. [1965, 'The Sound of Music', 'musical'],
  10. [1969, 'Midnight Cowboy', 'drama'],
  11. [1972, 'The Godfather', 'drama'],
  12. [1973, 'The Sting', 'comedy'],
  13. [1977, 'Annie Hall', 'comedy'],
  14. [1982, 'Ghandi', 'historical'],
  15. [1986, 'Platoon', 'action'],
  16. [1990, 'Dances with Wolves', 'western'],
  17. [1992, 'Unforgiven', 'western'],
  18. [1994, 'Forrest Gump', 'comedy'],
  19. [1995, 'Braveheart', 'historical'],
  20. [1997, 'Titanic', 'historical'],
  21. [1998, 'Shakespeare in Love', 'comedy'],
  22. [2000, 'Gladiator', 'action'],
  23. [2001, 'A Beautiful Mind', 'historical'],
  24. [2002, 'Chicago', 'musical'],
  25. [2009, 'The Hurt Locker','action'],
  26. [2010, 'The Kings Speech', 'historical'],
  27. [2011, 'The Artist', 'comedy'],
  28. [2012, 'Argo', 'historical'],
  29. [2013, '12 Years a Slave', 'drama'],
  30. [2014, 'Birdman', 'comedy'],
  31. [2015, 'Spotlight', 'drama'],
  32. [2016, 'Moonlight', 'drama'],
  33. [2017, 'The Shape of Water', 'fantasy']]
  34.  
  35. def editlist():
  36. global movies
  37. yearadd = int(input("Please enter a year between 1927 and 2019: "))
  38. titleadd = input("Please enter the movie title: ")
  39. catadd = input("Please enter the category of the movie: ")
  40. while yearadd < 1927 and yearadd > 2019: #maybe add "and not" to check for repeats - how DO i check for repeats?
  41. int(input('Year must be between 1927 and 2019. Try again: ')) #not catching this
  42.  
  43. movies += [str(yearadd)+ ',' + titleadd + ',' + catadd] #works but does wonky printing!
  44. movies.sort
  45.  
  46. menu =("""
  47. Movie List Menu
  48.  
  49. 1 - Display Movies by Year
  50. 2 - Display Movie and Category by Year
  51. 3 - Add movie and category to list for an entered year
  52. p - Print all Movies
  53. pc - Print by category
  54.  
  55. q - Quit
  56.  
  57. Enter your selection from the above items and hit 'Enter'
  58. """)
  59.  
  60. option = '0'
  61.  
  62. while option is not 'quit':
  63. print("\n"+ menu)
  64. selection = input('')
  65. print('\nSelection is '+ selection)
  66.  
  67. if selection == '1':
  68. print('\nDisplay by Year')
  69. year = int(input("\nEnter year: "))
  70. validYear = False
  71. while(not validYear):
  72. cnt = 0
  73. while(cnt<len(movies) and not validYear):
  74. if(movies[cnt][0]==year):
  75. validYear = True
  76. break
  77. cnt+=1
  78. if(not validYear):
  79. print("\nPlease re-enter your year")
  80. year = int(input("Enter year: "))
  81. print(movies[cnt][1])
  82.  
  83. elif selection == '2':
  84. print('\nDisplay Movie and Category by Year')
  85. year = int(input("\nEnter year: "))
  86. validYear = False
  87. while(not validYear):
  88. cnt = 0
  89. while(cnt<len(movies) and not validYear):
  90. if(movies[cnt][0]==year):
  91. validYear = True
  92. break
  93. cnt+=1
  94. if(not validYear):
  95. print("\nPlease re-enter your year")
  96. year = int(input("Enter year: "))
  97. print(movies[cnt][1]+ ", " +movies[cnt][2])
  98.  
  99. elif selection == '3':
  100. print('\nAdd movie and category to list for an entered year')
  101. editlist()#function here
  102.  
  103. elif selection == 'p':
  104. print('\nPrint all Movies - year, title, category')
  105. for i in movies:
  106. print(str(i[0]) + ', ' + str(i[1]+ ', ' + str(i[2])))
  107.  
  108. elif selection == 'pc':
  109. check = True
  110. print('\nPrint all Movies in Category - Year and Title')
  111. print('\nCategories are: drama, musical, comedy, historical, action, western, fantasy')
  112. category = input("\nPlease select a category: ")
  113. for i in movies:
  114. if i[2] == category:
  115. check = False
  116. print("\n", i[0], i[1])
  117. if check:
  118. print("\nNo matches found.")
  119.  
  120. elif selection == 'q':
  121. break
  122.  
  123. input("\n\nHit Enter to end program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement