I have created a code in thonny that takes 3 inputs to determine the price of an item. I also want to be able to provide a discount to the price if it meets certain requirement and only one discount is eligible and to print the results of the discount. if if no discount is eligible I want print just the price of the item.
Please see my code below what I have tried
if sqFt > BIG_DESK:
if wood == 'oak' or wood == 'mahog':
discount = DISC_1
discAmnt = discount * price
discPrice = price - discAmnt
elif wood == 'oak' or drawers > DISC_DRAWER:
discount = DISC_2
discAmnt = discount * price
discPrice = price - discAmnt
elif price > DISC_PRICE:
discount = DISC_3
discAmnt = discount * price
discPrice = price - discAmnt
print("\nThe price of the desk is $", format(price,',.2f'))
print("\nThe discounted price is $", format(discPrice,',.2f'))
print("\nYou qualified for a", format(discount,'.0%'),"and saved",format(discAmnt,',.2f'))
else:
print("\nThe price of the desk is $", format(price,',.2f'))
As stated before, if there is a discount able to be applied I want it to print the price, the price minus the discount, and the discount and discount amount.
I keep getting error at the else statement with error statement SyntaxError: invalid syntax
Aucun commentaire:
Enregistrer un commentaire