Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program that will allow a user to add, list, and delete items from a shopping list. Deliverables A source code Python file. A

Create a program that will allow a user to add, list, and delete items from a shopping list.

Deliverables

  • A source code Python file.
  • A Word document containing both source code and the screen print of the program outputs.

Lab Steps

The program should be modular. For example, you will want to have an add_item(shopping_list) function, a delete_item(shopping_list) function, a display_list(shopping_list) function, a display_menu() function, and a main().

Sample Output:

Welcome to the program!

1. Add an item

2. List all items

3. Delete an item

4. Exit

Enter a menu option: 2

1 : bananas

2 : apples

Enter a menu option: 1

Please enter the item: pears

pears was added to the shopping list

Enter a menu option: 2

1 : bananas

2 : apples

3 : pears

Enter a menu option: 3

Which number to delete: 3

pears was deleted

Enter a menu option: 2

1 : bananas

2 : apples

Enter a menu option: 4

have a great day!

Specifications:

  • The program should start with 2 items in the shopping list.
  • Don't forget to include at the end of the program the code:
    • if __name__ == "__main__": main();
  • Use this code for the delete_item(shopping_list) function:
def delete_item(shopping_list):
 number=int(input("Which number to delete: "))
 if number<1 or number>len(shopping_list):
 print("Invalid number ")
 else:
 item=shopping_list.pop(number-1)
 print(item," was deleted ")
 print()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

3. List your top 10 film mentors.

Answered: 1 week ago