Question: #Task: Create the empty data structure grocery_history = list() #Variable used to check if the while loop condition is met stop = 'go' while stop

#Task: Create the empty data structure

grocery_history = list()

#Variable used to check if the while loop condition is met stop = 'go'

while stop != 'q': item_name = input("Item name: ") quantity = int(input("Quantity purchased: ")) cost = float(input("Price per Item: ")) grocery_item = {'name':item_name, 'number': int(quantity), 'price': float(coast)} grocery_history.append(grocery_item) stop = input("Would you like to enter another item? Type 'c' for continue or 'q' to quit: ") grand_total = 0 print()

#Accept input of the name of the grocery item purchased. #Accept input of the quantity of the grocery item purchased. #Accept input of the cost of the grocery item input (this is a per-item cost).

#Create a dictionary entry which contains the name, number and price entered by the user.

#Add the grocery_item to the grocery_history list using the append function

#Accept input from the user asking if they have finished entering grocery items.

# Define variable to hold grand total called 'grand_total'

#Define a 'for' loop.

for grocery_item in grocery_history: item_total = grocery_item['number'] * grocery['price'] grand_total += item_total print("{} {} @ ${} ea ${}".format(grocery_item['number'], grocery_item['name'], grocery_item['price'], item_total)) #item_total = 0 print("Grand total : ",grand_total) #Calculate the total cost for the grocery_item. #Add the item_total to the grand_total #Output the information for the grocery item to match this example: #2 apple @ $1.49 ea $2.98 #Set the item_total equal to 0

#Print the grand total

#Task: Create the empty data structure grocery_history = list() #Variable used to

check if the while loop condition is met stop = 'go' while

Test Your Code Single ltem Check Input: nitk 2.99 Single Grocery Item Check Check It LAST RUN on 63/2019,4:4B 48 PM Check 1 failed Output: Item name: Quantity purchased: Price per Item: Traceback (most recent call last): File "grocery_list.py", line 20, in grocery item'name':item name, numb NameError: name 'coast' is not defined Expected: name tity purchased: per item : i you like to enter another item? to quit : 'c' for continue or Lk $2.99 ea $2.99 d total: $2.99

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!