Build a Discount Calculator - Build a Discount Calculator

Tell us what’s happening:

Hi everyone, I’m having some trouble with my the lab. I deleted my code because the tests stopped marking my answers as correct, even though they were working before.

I’ve already erased my cache and logged out/in, but the problem persists. I can’t see any visual feedback or updates on the code, and it’s making it impossible to keep coding. Has anyone dealt with this before? Any help would be appreciated!

Your code so far

def apply_discount(price, discount):

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Discount Calculator - Build a Discount Calculator

Hi @StephCH , welcome to freeCodeCamp’s forum !

You’re saying that

Is it true ? Do you have any save anywhere else ? Otherwise, I’m afraid your work is lost.

Is this a technical issue with the website ? If it is, I suggest you create a new topic in the freeCodeCamp support forum, where the bugs are treated. If you can, join some screenshots ! We’ll thank you for that.

Enjoy coding !

what code is being marked as incorrect but is correct?
you have shared a function definition but with no code inside, that is a syntax error and would cause all tests to fail

Sorry! I did it again; once more, it stopped working at step 4. Is there something that isn’t right? Is that why it’s giving an error? It used to work before, so that’s why I’m wondering."

def apply_discount(price, discount): #1 y 2
   if not isinstance(price, (int, float)): #3
      return 'The price should be a number'
   elif not isinstance(discount, (int, float)): #4
      return 'The discount should be a number'
   elif price <= 0: #5
      return 'The price should be greater than 0'
   elif discount <0 or discount > 100: #6
      return 'The discount should be between 0 and 100'
   else:
      print('Result:', apply_discount(100, 20))

what test is failing? what do you mean that it used to work?

You are not returning the final price with the discount applied and you are calling the function inside the function itself.

Test by printing your function call outside of the function.

I DIIIIIIIIIIIIIIIIIIIIIIIIIIIID IIIIIT!!! I did iiiiit!!! Don’t know how hahahahhaha, but I did it!!!

OMG!!! :rofl: