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 trialKim Monteiro
464 PointsDon't know what I should put in the else block...
Don't know what I should put in the else block...
def add(num1, num2):
try:
return float(num1) + float(num2)
except ValueError:
return None
else:
add(2, 4)
2 Answers
Steven Parker
231,269 PointsYou don't need an "else" since you return from the "try" and also from the "except".
But you have some other issues:
- anything that is part of a function must be indented more than the function "def" line
- you only need to define the function, you won't need to call it
Kim Monteiro
464 PointsThank you so much!