Question
USING PYTHON PROGRAMMING AND WHILE LOOPS (DO NOT USE FOR LOOPS) This program allows the user to create a grocery list, with the user being
USING PYTHON PROGRAMMING AND WHILE LOOPS (DO NOT USE FOR LOOPS)
This program allows the user to create a grocery list, with
the user being
allowed to
enter
items indefinitely, stopping only when they en
ter the sent
inel
value STOP.
If the user tries to enter an item already
in the list
, the
program should print out an error message and not add the duplicate to the
list.
You may NOT use the membership
in
operator for this
problem.
After
the user indicates they are done, their complete grocery list
should be
printed back out to them,
i
n the same order it was entered,
along with
the
total number of items on the
ir
list.
The program
must
m
ake
use of a
list to accomplish
t
hese tasks
!
SAMPLE OUTPUT:
Please enter a grocery item ('STOP' to exit):
STOP
There are 0 groceries in your list:
bash
-
4.1$ python hw4_part7.py
Please enter a grocery item ('STOP' to exit):
dog food
Please enter a grocery item ('STOP' to exit):
b
utter
Please enter a grocery item ('STOP' to exit):
dog
f
ood
Error: The item dog food is already in the list.
Please enter a grocery item ('STOP' to exit):
c
heese
Please enter a grocery item ('STOP' to exit):
dog food
Error: The item d
og food is already in the list.
Please enter a grocery item ('STOP' to exit):
steak
Please enter a grocery item ('STOP' to e
xit):
ice cream
Please enter a grocery item ('STOP' to exit):
s
teak
Error: The item
s
teak
is already in the list.
Please enter a grocery item ('STOP' to exit):
STOP
There are 5 groceries in your list:
dog food
butter
c
heese
steak
ice cream
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