 # My code - reason why I got an incorrect code

#1

Hello,
for this exercise I wrote this code:
price=250
if price>=300:
price - (price30/100)
elif (price>=200 and price<300):
print(price - (price
20/100))
elif (price>=100 and price<200):
price - (price10/100)
elif (price>=0 and price<100):
price - (price
5/100)
else:
price

and I got the message that this produces incorrect output.
when I put this code into pycharm, my code is correct.
what is the reason?

#2

Hi Jaksa,
This is Samreen Fatima from Educative.

In order to correct your code, consider the following:

1. Add the multiplication operator between the price and the following number, i.e. price * 20 instead of price20.
2. Store the discounted price in the price variable as mentioned in the lesson:

“The `price` variable has already been created. You can use it in your code and assign it a new value based on the discount.

This helps us to evaluate your newly calculated price.

The correct version of your code is as follows:

``````price=250
if price>=300:
price = price - (price*30/100)
elif (price>=200 and price<300):
price = price - (price*20/100)
elif (price>=100 and price<200):
price = price - (price*10/100)
elif (price>=0 and price<100):
price = price - (price*5/100)
else:
price
``````

Best Regards,