# File: moWeGroceries.py # Author: Dr. Gibson # Date: 9/28/2016 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that asks the user for # their grocery items, save it in a list, and prints out # the final list at the end. def main(): SENTINEL = "STOP" groceryList = [] # unlike print(), input() can't have multiple pieces separate by commas # instead, we need to concatenate everything into one string item = input("What do you want to buy? ('" + SENTINEL + "' to stop): ") while item != SENTINEL: groceryList.append(item) item = input("What do you want to buy? ('" + SENTINEL + "' to stop): ") print("Thank you for entering your groceries, you want to buy:") index = 0 while index < len(groceryList): print(groceryList[index]) index = index + 1 # don't forget to update the loop variable! main()