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 trialJohn Paul Masters
1,722 PointsTask 3 Help
I don't understand the last bit with the return and added floats, I don't know what to do
def add(num1, num2):
try:
return float(num1) + float(num2)
except ValueError:
return None
else:
return
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey John Paul,
You code is actually completely correct except for the indentations. Python is very "indent dependent," and if your off by one space, the code will break.
In this case, you didn't indent your try
block of code, so right now, it is outside of the method, instead of inside. Just fix up the indentation and the rest is good:
def add(num1, num2):
try:
return float(num1) + float(num2)
except ValueError:
return None
else:
return
Keep Coding! :)
Nick Colon
Courses Plus Student 4,395 PointsNick Colon
Courses Plus Student 4,395 PointsYou have almost everything!
You are just missing the return num1 and num2 on your else return on the end! but you got this!