Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Debug EOFError in Python program

Subject: Debug EOFError in Python program

Hi, If anyone can help me to remove the following error in Python program that runs in Codio.

Item name: 
Quantity purchased: 
Price per item: 
Would you like to enter another item?
Type 'c' for continue or 'q' to quit:
Item name: 
Traceback (most recent call last):
  File "grocery_list.py", line 21, in <module>
    item_name = input("Item name: n")
EOFError: EOF when reading a line
Expected:
Item name:
Quantity purchased:
Price per item:
Would you like to enter another item?
Type 'c' for continue or 'q' to quit:
1 milk @ $2.99 ea $2.99
Grand total: $2.99

Below is my code:

#Task: Create the empty data structure

grocery_item = {}

grocery_history = []

#Variable used to check if the while loop condition is met

stop = False

while not stop:

  #Accept input of the name of the grocery item purchased.

  item_name = input(“Item name: n”)

  #Accept input of the quantity of the grocery item purchased.

  quantity = input(“Quantity purchased: n”)

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

  cost = input(“Price per item: n”)

  #Using the update function to create dictionary entry which contains the name, number and price entered by the user.

  grocery_item = {‘name’:item_name, ‘number’:int(quantity), ‘price’:float(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.

  response = input(“Would you like to enter another item?nType ‘c’ for continue or ‘q’ to quit:n”)

if response == ‘q’:

 stop = True

# Define variable to hold grand total called ‘grand_total’

 grand_total = 0

#Define a ‘for’ loop.  

for item in grocery_history:

 #Calculate the total cost for the grocery_item.

  item_total = item[‘number’] * item[‘price’]

 #Add the item_total to the grand_total

  grand_total += item_total

 #Output the information for the grocery item to match this example:

 #2 apple @ $1.49 ea $2.98

  print(“%d %s @ $%.2f ea $%.2f” %(item[‘quantity’], item[‘item_name’], item[‘cost’], item_total))

 #Set the item_total equal to 0

  item_total = 0

#Print the grand total

  print(“Grand total: $%.2f” % grand_total)

 
"Looking for a Similar Assignment? Order now and Get 10% Discount! Use Code "Newclient"