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 trialkk kk
152 Pointshow to solve this,please answer
please help
def add(a,b):
try:
a=float(a)
b=float(b)
return a+b
except ValueError
return none
2 Answers
behar
10,799 PointsYou super close! But you seem to have some indentation errors. Remember that everytime we write a ":" we want to indent 4 blocks for the next instruction. You have done way to many indents after your try:. Secondly you need to have a ":" after you except ValueError. And it needs to be on the same line as try:.. It may be simpler just to see the code:
def add(a,b):
try:
a=float(a)
b=float(b)
return a+b
except ValueError:
return None
Tobiah Woeltjen
874 PointsI was having trouble with this question too. Have seen other answers, but this is the first one that worked.
kk kk
152 Pointskk kk
152 Pointsthank you so much