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 trialNoor Hafiza Binti Ibrahim
11,712 PointsBummer: 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?
# enter your code below
def mathy(divide,b,c):
divide = b/c
return divide
1 Answer
Jeff Muday
Treehouse Moderator 28,722 PointsThat 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
Leslio McKeown
Python Development Techdegree Student 9,441 PointsLeslio McKeown
Python Development Techdegree Student 9,441 Pointsthanks for giving a clear example while still leaving the rest to be solved by the student
Jeff Muday
Treehouse Moderator 28,722 PointsJeff Muday
Treehouse Moderator 28,722 PointsThanks... it's hard to know how much prompting to best help, but sometimes a little goes a long way!