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 trial
reza rahnama
Python Web Development Techdegree Student 1,118 PointsHelp with last question for Python Basic course
I have the following code which I am keep getting "Opps try again". I have looked at the community portal and I believe my code is correct. Can you please help and see what is it that I am missing in this : def add (exe1, exe2): try: a = float (exe1) b = float (exe2) total = (a + b)
except ValueError:
return None
else:
return total
1 Answer
reza rahnama
Python Web Development Techdegree Student 1,118 PointsI have just executed this code in Pycharm and it worked def add (exe1, exe2): try: a = float (exe1) b = float (exe2) total = (a + b)
except ValueError:
return None
else:
print (total)
add (2,3)
Not sure why it doesn't work in the questions for Python Basic and as this is the last activity in this course, I can't move forward... frustrating !
Namrata Lamba
1,347 PointsNamrata Lamba
1,347 PointsI've tried the same thing! Getting the error
def add(num1,num2): try: float(num1) float(num2) except ValueError: return None else: return (float(num1)+float(num2))