My code keeps saying ‘int’ object is not callable when I run it. How to fix this?
Your code so far
def apply_discount(price, discount):
if not isinstance(price (int, float)):
return 'The price should be a number'
elif isinstance(price(int, float)):
if price == 0:
return 'The price should be greater than 0'
else:
return price % discount
if not isinstance(discount(int, float)):
return 'The discount should be a number'
elif isinstance(discount(int, float)):
if discount < 0 or discount > 100:
return 'The discount should be between 0 and 100'
else:
return price % discount
apply_discount(7, 4)
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Challenge Information:
Build an Apply Discount Function - Build an Apply Discount Function
Please review this theory lecture for the correct syntax to use with isinstance when you’re checking a variable against multiple types.
Also, please format your code as follows when you post it –
There are two ways you can format your code to make it easier to read and test:
After you copy/paste your code into the editor, select it by dragging your cursor over it then click the (</>) button in the toolbar to automatically wrap your code in backticks. (You can click on the animated demo image below to enlarge it.)
Manually add three backticks on a new line above your code and on a new line after your code. Note that a backtick is NOT the same as a single quote('). To find the backtick key on your keyboard, see this post.
To see changes to your post as you make them, you can click the (M+) button on the toolbar to bring up the rich text editor: