Question
Stuck on this, Python 3.6 # CMPT141 Assignment 4. Q1 # Collection of books in Library. # To practice creating and manipulating lists. # Starter
Stuck on this, Python 3.6
# CMPT141 Assignment 4. Q1
# Collection of books in Library.
# To practice creating and manipulating lists.
# Starter code
def print_menu():
"""
Prints the program menu to the console.
:return: None
"""
print('Menu:')
print('a - Add new book')
print('d - Delete ruined book')
print('p - Display all books')
print('s - Search for a book.')
print('e - Exit program.')
print('Enter the letter next to the menu item you wish to use: ', end="")
# Initialize the library_books to be empty.
library_books = []
# Print the menu and ask for the first menu selectionl.
print_menu()
action = input()
print()
while action != 'e':
if action == 'a':
# TODO: 1. Prompt the user to input a book title and then read the title from the console.
# TODO: 2. Add the entered title to the end of the list referred to by library_books.
# TODO: 3. Remove the print('Not implemented yet.') line.
print('Not implemented yet.')
elif action == 'd':
# TODO: 1. Prompt the user to input a book title and read a title from the console.
# TODO: If the book is in the library, remove it from the list library_books.
# TODO: 2. Print a message indicating whether a book was removed or not.
# TODO: 3. Remove the print('Not implemented yet.') line.
print('Not implemented yet.')
elif action == 'p':
'p' [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# TODO: 1. Print a numbered list of titles in the library_books list on the console.
# TODO: one per line. (See the sample output to see how this should look)
# TODO: 3. Remove the print('Not implemented yet.') line.
print('Not implemented yet.')
elif action == 's':
# TODO: 1. Prompt the user to input a title and read a title from the console.
# TODO: 2. If the title is in the list library_books print "Yeay! Book is found in the library."
# TODO: to the console. If the title is not in the list libray_books, print
# TODO: "Oops! Book not found." to the console.
# TODO: 3. Remove the print('Not implemented yet.') line.
print('Not implemented yet.')
elif action == 'e':
pass
else:
print('That was not a valid choice! Try again.')
print_menu()
action = input()
print()
print("Have a nice day! Goodbye.")
Library collection. You will complete a partially written program that will allow her to add new books in the collection, remove ruined book from the collection, determine whether a book exists in the library, and print the entire collection to the console Consider the given starter code in a4q1-starter. py. The starter code is functional in that the interactive menu works, but when you select a menu item, it doesn't actually do anything (with the excepiton of Exit') You should try running it before you write any code to see how it behaves. Then, fill in your own code where the comments tell you to. Each comment that you need to address is marked with the word TODo and explains what you should do Sample Run Here is an example of how your program's console output might look. Green text was entered by the user Menu: a -Add new book d Delete ruined book p Display all books s Search for a book. eEit program. Enter the letter next to the menu item you wish to use: a Enter the title of book: Archie 's funhouse Menu: a Add new book d Delete ruined book p - Display all books s Search for a book. e Exit program. Enter the letter next to the menu item you wish to use: a Enter the title of book:Meet Rosetta Menu a -Add new book d - Delete ruined book p - Display all books s Search for a book e Exit program Enter the letter next to the menu item vyou wish to use: a Enter the title of book The disappearing fruit Menu a Add new book d Delete ruined book p - Display all books s Search for a book e - Exit program. Enter the letter next to the menu item you wish to use: p 1. Archie's funhouse 2. Meet Rosetta 3. The disappearing fruit
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started