# Build a Discount Calculator - Build a Discount Calculator

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

<div class="post-metadata">

**Author:** ![jordac](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jordac/32/409156_2.png) [@jordac](https://forum.freecodecamp.org/u/jordac)\
**Post date:** [February 3, 2026, 4:01am UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776684/1 "2026-02-03T04:01:43Z")

</div>

### Tell us what’s happening:

I can’t figure out why it doesn’t like my functions output as it matches what the stories have asked for? I have read all of the recent posts with the same issue as me but I must be simple because I still cant figure it out, please help!

### Your code so far

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

apply_discount("20", 20)
apply_discount(20, "20")
apply_discount(-1, 20)
apply_discount(20, -1)
apply_discount(100, 20)
apply_discount(200, 50)
apply_discount(50, 0)
apply_discount(1, 100)
apply_discount(74.5, 20.0)

```

### Your browser information:

User Agent is: `Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.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:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [February 3, 2026, 5:22am UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776684/2 "2026-02-03T05:22:46Z")

</div>

What your function returns?

---

<div class="post-metadata">

**Author:** ![jordac](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jordac/32/409156_2.png) [@jordac](https://forum.freecodecamp.org/u/jordac)\
**Post date:** [February 3, 2026, 6:27am UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776684/3 "2026-02-03T06:27:43Z")

</div>

The discount should be a number  
The price should be greater than 0  
The discount should be between 0 and 100  
80.0  
100.0  
50.0  
0.0  
59.6

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [February 3, 2026, 8:01am UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776684/4 "2026-02-03T08:01:00Z")

</div>

To confirm what your function returns, it can be wrapped with the `print` function. With additional note, ie.

```python
print('Result:', apply_discount(100, 20))

```

Per specification result for this case should be `80`, so there should be _Result: 80_ in the console after running the above code.

---

<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, 8:01am UTC](https://forum.freecodecamp.org/t/build-a-discount-calculator-build-a-discount-calculator/776684/5 "2026-03-03T08:01:23Z")

</div>

Closed on March 3, 2026, 8:01am UTC

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