# File: groceries_v2.py # Author: Dr. Gibson # Date: 2/13/2017 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that allows the user # to create a grocery list, using "STOP" to quit def main(): print("Welcome to the Grocery Manager 2.0") # initialize the grocery list to be empty groceries = [] # PRIMING READ (tell the user the sentinel value) item = input("Please enter an item, or 'STOP' to stop: ") # continue until the user chooses to stop while item != "STOP": # store item in groceries, then ask for another groceries.append(item) item = input("Please enter an item, or 'STOP' to stop: ") # use a second while loop to print out all of the # groceries, with each item on a separate line count = 0 while count < len(groceries): # use the variable 'count' to index into the groceries list print(groceries[count]) count += 1 main()