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

Convert your arguments to floats

float(a) float(b) return (a+b)

trial.py
def add (a,b):
  float(a)
  float(b)
  return(a+b)

1 Answer

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

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)

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