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 trialGeorge Lugo
Python Web Development Techdegree Student 922 Pointsi dont know what is wrong with my code
try (john, kelsey): total = float(john) + float(kelsey) except ValueError: return None else: return total
try (john, kelsey):
total = float(john) + float(kelsey)
except ValueError:
return None
else:
return total
2 Answers
Juan Martin
14,335 PointsHello George,
The error I see is that you're passing arguments to the "try" and not defining the function, those arguments should go inside the function instead, like this:
def add(john, kelsey):
try:
total = float(john) + float(kelsey)
except ValueError:
return None
else:
return total
Hope this helps :)
Steven Parker
231,248 PointsI already answered both your previous question and your original question.
But I'll repeat it here:
Each task of the challenge builds on the last.
In a multi-task challenge like this, each task builds on the work you did in the previous steps.
It looks like you are on task 3, but some of what you needed for tasks 1 and 2 is missing here. Remember the challenge started out by building a function named add? The other tasks modify how the function works, but everything should still be within that function.
Also remember than anything that belongs inside a function must be indented.