Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Program name: Maggie_Potts_A5.py
- #Movie List Maintenance
- #Author: Maggie Potts
- movies = [[1939, 'Gone with the Wind', 'drama'],
- [1943, 'Casablanca', 'drama'],
- [1965, 'The Sound of Music', 'musical'],
- [1969, 'Midnight Cowboy', 'drama'],
- [1972, 'The Godfather', 'drama'],
- [1973, 'The Sting', 'comedy'],
- [1977, 'Annie Hall', 'comedy'],
- [1982, 'Ghandi', 'historical'],
- [1986, 'Platoon', 'action'],
- [1990, 'Dances with Wolves', 'western'],
- [1992, 'Unforgiven', 'western'],
- [1994, 'Forrest Gump', 'comedy'],
- [1995, 'Braveheart', 'historical'],
- [1997, 'Titanic', 'historical'],
- [1998, 'Shakespeare in Love', 'comedy'],
- [2000, 'Gladiator', 'action'],
- [2001, 'A Beautiful Mind', 'historical'],
- [2002, 'Chicago', 'musical'],
- [2009, 'The Hurt Locker','action'],
- [2010, 'The Kings Speech', 'historical'],
- [2011, 'The Artist', 'comedy'],
- [2012, 'Argo', 'historical'],
- [2013, '12 Years a Slave', 'drama'],
- [2014, 'Birdman', 'comedy'],
- [2015, 'Spotlight', 'drama'],
- [2016, 'Moonlight', 'drama'],
- [2017, 'The Shape of Water', 'fantasy']]
- def editlist():
- global movies
- yearadd = int(input("Please enter a year between 1927 and 2019: "))
- titleadd = input("Please enter the movie title: ")
- catadd = input("Please enter the category of the movie: ")
- while yearadd < 1927 and yearadd > 2019: #maybe add "and not" to check for repeats - how DO i check for repeats?
- int(input('Year must be between 1927 and 2019. Try again: ')) #not catching this
- movies += [str(yearadd)+ ',' + titleadd + ',' + catadd] #works but does wonky printing!
- movies.sort
- menu =("""
- Movie List Menu
- 1 - Display Movies by Year
- 2 - Display Movie and Category by Year
- 3 - Add movie and category to list for an entered year
- p - Print all Movies
- pc - Print by category
- q - Quit
- Enter your selection from the above items and hit 'Enter'
- """)
- option = '0'
- while option is not 'quit':
- print("\n"+ menu)
- selection = input('')
- print('\nSelection is '+ selection)
- if selection == '1':
- print('\nDisplay by Year')
- year = int(input("\nEnter year: "))
- validYear = False
- while(not validYear):
- cnt = 0
- while(cnt<len(movies) and not validYear):
- if(movies[cnt][0]==year):
- validYear = True
- break
- cnt+=1
- if(not validYear):
- print("\nPlease re-enter your year")
- year = int(input("Enter year: "))
- print(movies[cnt][1])
- elif selection == '2':
- print('\nDisplay Movie and Category by Year')
- year = int(input("\nEnter year: "))
- validYear = False
- while(not validYear):
- cnt = 0
- while(cnt<len(movies) and not validYear):
- if(movies[cnt][0]==year):
- validYear = True
- break
- cnt+=1
- if(not validYear):
- print("\nPlease re-enter your year")
- year = int(input("Enter year: "))
- print(movies[cnt][1]+ ", " +movies[cnt][2])
- elif selection == '3':
- print('\nAdd movie and category to list for an entered year')
- editlist()#function here
- elif selection == 'p':
- print('\nPrint all Movies - year, title, category')
- for i in movies:
- print(str(i[0]) + ', ' + str(i[1]+ ', ' + str(i[2])))
- elif selection == 'pc':
- check = True
- print('\nPrint all Movies in Category - Year and Title')
- print('\nCategories are: drama, musical, comedy, historical, action, western, fantasy')
- category = input("\nPlease select a category: ")
- for i in movies:
- if i[2] == category:
- check = False
- print("\n", i[0], i[1])
- if check:
- print("\nNo matches found.")
- elif selection == 'q':
- break
- input("\n\nHit Enter to end program")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement