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 trialJoseph Duarte
468 PointsI can't seem to pass challenge task 3 of 3:
def add(n1,n2): try: return float(n1) + float (n2) except ValueError: return ("None") else: return float(n1) + float (n2)
Thx
def add(n1,n2):
try:
return float(n1) + float (n2)
except ValueError:
return ("None")
else:
return float(n1) + float (n2)
1 Answer
Gavin Ralston
28,770 PointsYou don't need quotes around None
In fact, you don't need the else statement in this case, either, although that'll work just fine anyway. You'll either return None or the sum of the input values.
Joseph Duarte
468 PointsJoseph Duarte
468 PointsThank you Gavin
In addition to your answer the other issue was the indentation in the try block. I did not have the whole try block indented.
Joseph Duarte
468 PointsJoseph Duarte
468 PointsThank you Gavin
In addition to your answer the other issue was the indentation in the try block. I did not have the whole try block indented.
Gavin Ralston
28,770 PointsGavin Ralston
28,770 PointsAh yeah, I saw the indentation but thought maybe that was a cut-and-paste problem. Good to see you caught that :)