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 trialchristianfigueroa
13,595 PointsI'm getting an error say 'add' not defined
Not sure why its spitting out this error.
def add(x,y):
try:
return float(x)+float(y)
except ValueError:
return none
else:
return float(x)+float(y)
2 Answers
jcorum
71,830 PointsActually it is returning none when it should be None
Jason Anders
Treehouse Moderator 145,860 PointsHey Christian,
It seems like a weird error to be spitting out considering that it's just a small typo that is throwing it... but I guess that's coding for you.
The return in your except
clause is returning none
with a lower case 'n' when it should be None
with an uppercase 'N'
Just fix that up and you're good to go.
EDITED: Was using 'true/True' instead of 'none/None' in my reply. That was my misreading. Sorry
christianfigueroa
13,595 PointsThanks a bunch for your help! now i can continue learning Python =D
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsThanks jcorum
I caught that just as I hit Post! Edited my answer to reflect the correct term. :)