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

1 Answer

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Hi,

  • you need to remove the space between "add" and "(a, b)"
  • remove the parenthesis when you return two variables
def add(a, b): # remove space between "add" and "(a, b)"
  return float(a) + float(b)

edit answer with correct code

Patrick Mockridge
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Patrick Mockridge
Full Stack JavaScript Techdegree Graduate 45,611 Points

Actually I wasn't converting a and b into floats, what I needed to do was return (float(a)+float(b)) or assign new variables c=float(a) d=float(b) return(c+d)

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

edit with your code

when you return something you don't have to wrap with parenthesis:

def add(a, b):
    return float(a) + float(b)

# or assign new variables

def add(a, b):
    c = float(a)
    d = float(b)
    return c + d