# Build a Discount Calculator - Build a Discount Calculator

**URL:** <https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776761>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [February 3, 2026, 1:37pm UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776761 "2026-02-03T13:37:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aoc82500](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/aoc82500/32/379393_2.png) [@aoc82500](https://forum.freecodecamp.org/u/aoc82500)\
**Post date:** [February 3, 2026, 1:37pm UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776761/1 "2026-02-03T13:37:01Z")

</div>

### Tell us what’s happening:

my code can’t pass the test 5 and further tests which says “When apply\_discount is called with a price lower than or equal to 0, it should return The price should be greater than 0” and same error in the discount test and i can’t find the error in my code. Can you please help me ?

### Your code so far

```py
def apply_discount(price, discount):
    if not isinstance(price, (int, float)):
        return 'The price should be a number'
    elif discount != int or discount != float:
        return 'The discount should be a number'
    elif price <= 0:
        return "The price should be greater than 0"
    elif discount <= 0 or discount > 100:
        return "The discount should be between 0 and 100"
    else:
        return (price - discount) / price * 100

```

### Your browser information:

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

### Challenge Information:

Build a Discount Calculator - Build a Discount Calculator

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/python-v9/lab-discount-calculator/build-a-discount-calculator)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 3, 2026, 2:39pm UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776761/2 "2026-02-03T14:39:52Z")

</div>

test it, what does it print? `print(apply_discount(-5, 25))`

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [March 3, 2026, 2:40pm UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776761/3 "2026-03-03T14:40:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
