Question

NOTE: I ONLY NEED THE CODE FOR THIS PART: "3 - add movie and category to list for an entered year". YOU DON'T HAVE TO GIVE ME THE CODE FOR MENU OPTIONS 1, 2, pc, p, OR q BECAUSE I HAVE THAT ALREADY. ONLY 3!

EDIT: THIS IS FOR PYTHON 3.8.

In this assignment you are to enhance the movie list display program from Assignment 4 to help maintain a list of movies thatThe following is a sample menu to show how the options might be presented to the user: menu 1 - display winning movie by year

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def prompt():
    
k=1
while k==1:
    k=0
    year = input('Enter the year: ')
    if not year.isnumeric():
        print('Please enter an integer value for year')
        k=1
    else:
        year=int(year)
        if year<1927 or year>2019:
            k=1
            print('Year must be between 1927 and 2019 inclusive.')
    title=input('Enter title: ')
    while len(title)>40:
        title=input('Title must not exceed 40 characters. Enter again: ')
    cat=input('Enter category: ')
    while cat not in ['drama','western','historical','musical','comedy','action','fantasy','scifi']:
        cat=input('Invalid category! Enter again: ')
    return [year,title,cat]

##code to run when option 3 is selected
movie=input('Enter movie name: ')
j=-1
for i in range(len(movies)):
    if movies[i][1]==movie:
        j=i
        break
if j!=-1:
    print('Year: {:d} Title: {:s} Category : {:s}'.format(movies[i][0],movies[i][1],movies[i][2]))
    choice=input('Do you want to replace it with new information? (y/n) ')
    if choice.lower()=='y':
        movies[j]=prompt()
        print('Entry updated')
else:
    movieEntry=prompt()
    i=-1
    for j in range(len(movies)):
        if movies[j][0]>movieEntry[0]:
            i=j
            break
    if i==-1:
        movies.append(movieEntry)
        print('Entry added')
    else:
        movies.insert(i,movieEntry)
        print('Entry added')

Enter movie name: The Godfather Year: 1972 Title: The Godfather Category : drama Do you want to replace it with new informati

Enter movie name: dfd Enter the year: 1966 Enter title: A Man for all seasons Enter category: drama Entry added

Add a comment
Know the answer?
Add Answer to:
NOTE: I ONLY NEED THE CODE FOR THIS PART: "3 - add movie and category to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For Python 3.8! Copy and paste the following bolded code into IDLE: movies = [[1939, 'Gone...

    For Python 3.8! Copy and paste the following bolded code into IDLE: 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,...

  • This homework problem has me pulling my hair out. We are working with text files in Java using Ne...

    This homework problem has me pulling my hair out. We are working with text files in Java using NetBeans GUI application. We're suppose to make a movie list and be able to pull up movies already in the text file (which I can do) and also be able to add and delete movies to and from the file (which is what I'm having trouble with). I've attached the specifications and the movie list if you need it. Any help would...

  • in visual basic ........Create a project that displays the aisle number of a movie category in...

    in visual basic ........Create a project that displays the aisle number of a movie category in a label. The movie categories will be in a list box. Store the aisle numbers and categories in an array. A Search button should locate the correct location from the array and display it in a label. Make sure that the user has selected a category from the list and use the list box SelectedIndex property to find the appropriate aisle number. Table Data...

  • Need a program in python. Asterix and Obelix want to store and process information about movies...

    Need a program in python. Asterix and Obelix want to store and process information about movies they are interested in. So, you have been commissioned to write a program in Python to automate this. Since they are not very computer literate, your program must be easy for them to use. They want to store the information in a comma separated text file. Using this they would need to generate a report – see all items AND show a bar chart...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

  • Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director,...

    Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only....

    Please i need the .H, .cpp and main.cpp files. Please use vector. its for my midterm so correct code that can run only. Thank you. Pointers and Dynamic Memory – Chapter 11 1. Write code using pointers and the Accounts class from week 1 assignment as follows – create a program in which you a. Create 10 accounts using an array with id’s 0 to 9 and refer to each account using pointer notation b. Add an initial balance of...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT