Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Technical Interview Prep: Python Basics Basic Python How Do You Like Them Apples

Noor Hafiza Binti Ibrahim
Noor Hafiza Binti Ibrahim
11,616 Points

Bummer: Uh oh, I didn't get the correct value returned. It should have been 50. Instead, it was None

What did i miss? What’s wrong with my code?

mathy.py
# enter your code below
def mathy(a, b, c):
    if a == 'add':
        return b+c
    elif a == 'substract':
        return b-c
    elif a == 'multiply':
        return b*c
    elif a == 'divide':
        return b/c
    else:
        return None

2 Answers

In the line elif a == 'substract':, you misspelled subtract. Other than that, your code looks fine.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,683 Points

Try passing in some value on a function call.

It looks to me like you've got your function but it needs to do something with some values and you get those values when you call the function.

So the first parameter a, is where you get the string and how the program decides what kind of calculation to make.

e.g.

mathy('divide', 15, 5)
Noor Hafiza Binti Ibrahim
Noor Hafiza Binti Ibrahim
11,616 Points

def mathy(divide,b,c): divide = b/c return divide

Now i got: Bummer: Uh oh, I didn't get the correct value returned. It should have been 59. Instead, it was 0.84375