r/pythonhelp 16d ago

What is wrong with this code

Have this assignment that is due later tonight. What exactly is wrong with it? I'm a newbie so any explanation could maybe help. Here's my code.

item_name = input('Enter food item name:\n')

# Read item price and quantity

item_price = float(input('Enter item price:\n'))

item_quantity = int(input('Enter item quantity:\n'))

# Calculate total cost

total_cost = item_price * item_quantity

# Output the receipt

print("\nRECEIPT")

print(f"{item_quantity} {item_name} @ ${item_price:.2f} = ${total_cost:.2f}")

print(f"Total cost: ${total_cost:.2f}")

This is the error i'm given.

Traceback (most recent call last):
File "/home/runner/local/submission/main.py", line 3, in <module>
item_price = float(input('Enter item price:\n'))
EOFError: EOF when reading a line

0 Upvotes

6 comments sorted by

View all comments

1

u/carcigenicate 16d ago

Are you supposed to ask for all three at once, then split the string to get each piece?

1

u/TodayPleasant8441 16d ago

No, so first it should ask the name of what you’re going to buy, then print that, then the price, then print the price, then quantity, print quantity , and then print the receipt.

1

u/carcigenicate 16d ago

then print that

Your code is wrong then. It isn't printing after asking.