I am trying to make a program related to money and the user needs to input a decimal. But it always gives me an error. Here is the code:
price = input("What is the price of your vegetable?")
pounds = input("How many pounds did you buy?")
price = int(price)
pounds = int(pounds)
if pounds < 5:
price = price * 1
print("Your price is " + str(price))
elif pounds < 10:
price = price * 0.90
print("Your price is " + str(price))
elif pounds < 20:
price = price * 0.80
print("Your price is " + str(price))
elif pounds > 30:
price = price * 0.75
print("Your price is " + str(price))
And here is the error:
What is the price of your vegetable?6.72
How many pounds did you buy?4
Traceback (most recent call last):
File "C:/Users/Jerry Cui/Documents/pricediscount.py", line 4, in <module>
price = int(price)
ValueError: invalid literal for int() with base 10: '6.72'
Where is the problem?