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 trialDustin Asevedo
1,367 PointsNot sure what to put for the "try" part
I have tried a multitude of things for the "try" part, but just can't seem to find anything for it that works
def add(num1, num2):
try:
except ValueError:
return None
else:
return float(num1) + float(num2)
add()
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsin the try block you are trying to cast to float, so for example myVar = (float)myVar. then in the return you just return myVar + myVar2. they are being cast in the try block so you can just add them in the return.
Ryan Dickinson
775 PointsDid you figure out what the task wants you to use there? I'm stuck in the same spot. I don't understand what the try block needs to be in order to progress. I know it should initiate the except block in catching non number arguments passed to the function, but how/what/does it need to be?