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 trialJeff Ness
Front End Web Development Techdegree Student 8,921 PointsI'm stuck. Think I'm doing the try: incorrectly.
have no idea
def add(num1, num2):
try:
numb1=int(num1)
numb2=int(num2)
except ValueError:
return None
else:
newnum1=float(numb1)
newnum2=float(numb2)
return(newnum1+newnum2)
1 Answer
Umesh Ravji
42,386 PointsHi Jeff, it looks like your using it reasonably, but that you aren't doing what the question is asking you to do. Rather than trying to convert to int() make sure you are using float(), a few minor changes, but almost there :)
def add(num1, num2):
try:
numb1=float(num1)
numb2=float(num2)
result = numb1 + numb2;
except ValueError:
return None
else:
return result