Question: This is my syntax in python: def main(): developerInfo() #unit price unit_price = 99 #user purchase user_unit_purchase = int(input('Number of units purchased is:')) #discount rate

This is my syntax in python:

def main(): developerInfo() #unit price unit_price = 99

#user purchase user_unit_purchase = int(input('Number of units purchased is:')) #discount rate for different conditions if user_unit_purchase < 10: discount = '0%' elif user_unit_purchase < 20: discount = '20%' elif user_unit_purchase < 50: discount = '30%' elif user_unit_purchase < 70: discount = '35%' elif user_unit_purchase < 100: discount = '40%' else: discount = '50%'

#subtotal of the price subtotal_user = user_unit_purchase * unit_price discount_apply = discount * subtotal_user total_final = subtotal_user - discount_apply

#print the result print ( 'Discount applied is: ', discount) print ( 'Total saving due to discount is: ', format(discount_apply,',.2f'),sep='') print ( 'The total cost of the purchase is: ', format(total_final,',.2f'),sep='')

And it said has this problem: File "/Users/shadi/Downloads/programming 5 (1).py", line 60, in main total_final = subtotal_user - discount_apply TypeError: unsupported operand type(s) for -: 'int' and 'str'

how should i change my syntax?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!