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

Python Python Basics (2015) Logic in Python Try and Except

Debasis Nath
Debasis Nath
3,316 Points

i have converted the arguments in to floats it's showing error?

def add (x,y): x=float(x) y=float(y)

trial.py
def add (x,y):
      x=float(x)
        y=float(y)
Debasis Nath
Debasis Nath
3,316 Points

it's juts showing bummer !

2 Answers

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Hey Debasis Nath

So two things here. Python tries to interpret whitespace, uses it to figure out where your blocks of code are at. Best way I could describe it is...

def add (x,y):
    x=float(x) #thinks this is part of a block
         y=float(y) #thinks this is part of another block 

vs.

def add (x,y):
    x=float(x) #these are within the same block.
    y=float(y)

Also to pass this challenge it says that you must add them up and return the total. So once you have that piece it should pass.

Let me know if that helps!

jacksonpranica
jacksonpranica
17,610 Points

Isn't your error coming from the fact that it wants you to return a value?

So don't you want to

return x+y

at the end of your function?

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Yes it will be, after he fixes the other error. RIght now he is getting a "Bummer, Try again" once he fixes indentation. He will get a different error resulting from not returning. ;)