Question: In this section you will loop through the grocery_history list. For each item, you will: Print the number of that item purchased Print the name

In this section you will loop through the grocery_history list. For each item, you will:
Print the number of that item purchased
Print the name of the item
Print the price paid for all of those items purchased
Add this price to the grand total for the entire list.
Your results will look similar to this:
2 Apple @ 1.49 ea $2.98
1 milk @ $3.99 ea $3.99
Grand total : $6.97
 In this section you will loop through the grocery_history list. For

ection provide output to the conso Le #Task: Create the empty data structure grocery-item# {} grocery-history {} #variable used to check if the while loop condition is met stop go while stop : #Accept input of the name of the grocery item purchased. item-name input("milk") #Accept input of the quantity of the grocery item purchased. quantity int (input("1")) #Acceptinput of the cost of the grocery item input (this 1s a per-item cost). cost float (input (2.99)) #create a dictionary entry which contains the name , number and price entered by the user. grocery-item i {'name':iten-name, 'number' :quantity, 'price' :cost) # #Add the grocery-item to the grocery-history list using the append function grocery history.append (grocery item) Accept input from the user asking if they have finished entering grocery items. stop input("Do you need to enter another item?1nType 'c to continue or 'q' to quit:" # Define variable to hold grand total cated ,grand-total, grand total &Define a 'for' loop. for iten in range(o,Len(grocery_history)): Calculate the total cost for the grocery-item. iten-total (grocery-history[1tem] [.number'] Add the item-total to the grand-total grocery.history[iten]["price']) * grand-total tem-total #Output the information for the grocery item to match this example: #2 apple e $1.49 ea $2.98 print) #Set the item-total equal to iten total 0 #print the grand total print (grand total) Python

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!