Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Noor Hafiza Binti Ibrahim
Noor Hafiza Binti Ibrahim
11,712 Points

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

How do i get the correct value?

mathy.py
# enter your code below
def mathy(divide,b,c):
    divide = b/c
    return divide

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,722 Points

That was unexpected, you might try rethinking your approach somewhat. The first variable is an operation that comes in as a string. The other variables are numeric.

So you would write something like this:

def mathy(operation, x, y):
    if operation == 'divide':
        answer = x / y
    if operation == 'multiply':
        answer = x * y

    # YOUR CODE FOR ADD

    # YOUR CODE FOR SUBTRACT

    return answer
Jeff Muday
Jeff Muday
Treehouse Moderator 28,722 Points

Thanks... it's hard to know how much prompting to best help, but sometimes a little goes a long way!