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 50. Instead, it was None
What did i miss? Whatβs wrong with my code?
# 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
jb30
44,806 PointsIn the line elif a == 'substract':
, you misspelled subtract. Other than that, your code looks fine.
Jonathan Grieve
Treehouse Moderator 91,253 PointsTry 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
11,712 Pointsdef 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