Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Bo Chen
Courses Plus Student 848 PointsI'm not sure what to put for the else
The instructions say to add an else but I'm not sure what to put in the else
def add(num1, num2):
try:
return(float(num1) + float(num2))
except ValueError
return(None)
2 Answers

juliansteffen
9,802 PointsDear Bo,
that's pretty good, just a little Syntax mistake you need to finish the line with :
except ValueError:
return("And here something that explain the Error: Like \"num1\" or \"num2\" coulnd't cast to float")
Greetings Julian

juliansteffen
9,802 PointsDear Bo,
actually for this "task" you don't need a else Block. In words you try to cast and add the two numbers and might an error will happen you return a information or do something eles inside of
except ValueError:
Like i wanna do something a+b but if an error happen "catch" this error and do something else mostly by this course just return a errormessage.
Greetings Julian
Bo Chen
Courses Plus Student 848 PointsBo Chen
Courses Plus Student 848 PointsWell actually, I'm supposed to add an else statement after the except block but I can't figure out what I'm supposed to put in the else block.