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 trialseong lee
4,503 PointsHelp me with this please
on python basics I am getting confused on the third task for try and except function exercises
def add(one, two):
try:
num3 = float (one) + float (two)
except ValueError:
return None
else:
return num3
5 Answers
Steven Parker
231,269 PointsBe careful with indentation.
Remember that to be considered part of a function, each line must be indented more than the def Β line.
Otherwise, your code looks good, so once you fix the indentation you should pass.
seong lee
4,503 Pointsthank you
seong lee
4,503 PointsIt still does not work actually Can you help me please
Steven Parker
231,269 PointsReally? See the example I added to my answer. Did you do something else?
seong lee
4,503 Pointsoh i'm very sorry I accidentally put a semicolon between except and ValueError
seong lee
4,503 Pointsand thank you, i was able to pass
Steven Parker
231,269 PointsSteven Parker
231,269 PointsUsing your code and changing only the indentation, I got this to pass: