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 trialJoel Corey
2,728 PointsTrial.py NameError: name 'add' is not defined
I have tried quite a few iterations, not sure what I am doing wrong but this challenge keeps erroring on NameError: name 'add' is not defined.
The following code runs just fine on my computerm, please excuse the horrible formatting with the pasted code:
def add(arg1, arg2): try: total = float(arg1) + float(arg2) except ValueError: return none else: return total
derp = add(2, 1) print(derp)
Thanks!
def add(arg1, arg2):
try:
return float(arg1) + float(arg2)
except ValueError:
return none
2 Answers
Ryan Ruscett
23,309 PointsNo worries,
You were right, you just forgot to capitalize the N in None in your return statement. Just fix that and you should be all set to go.
Joel Corey
2,728 PointsHey thanks! As I suspected it was something deserving of a facepalm/headdesk moment.