Question
IN PYTHON ONLY Write a menu-driven program that allows a user to create a shopping list. The user should have the option to add an
IN PYTHON ONLY
Write a menu-driven program that allows a user to create a shopping list. The user should have the option to add an item, remove an item, sort and print the list container. There should also be an option to quit. If the user attempts to remove an item that is not on the list, the program should not crash (i.e., you should check if the item is in the list before attempting to remove it).
If the user chooses to print the list, the printed list should be numbered. Do user validation to ensure that the user enters a valid choice from the menu.
Example of expected output:
to add an item to the list:
-------------------------
a - add item
r - remove item
s - sort shopping list
p - print shopping list
q - quit
--------------------------
Please enter your choice: a
What is the name of the new item: apples
to print a list:
Please enter your choice: p
1 : apples
2 : cherries
3 : bananas
4 : plums
5 : strawberries
to sort a list:
Please enter your choice: s
-------------------------
a - add item
r - remove item
s - sort shopping list
p - print shopping list
q - quit
--------------------------
Please enter your choice: p
1 : apples
2 : bananas
3 : cherries
4 : plums
5 : strawberries
to remove an item from a list:
What item do you wish to remove: cofefe
Could not find that item on the list.
-------------------------
a - add item
r - remove item
s - sort shopping list
p - print shopping list
q - quit
--------------------------
to quit the program:
-------------------------
a - add item
r - remove item
s - sort shopping list
p - print shopping list
q - quit
--------------------------
Please enter your choice: q
>>>
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