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

Help with the trial.py challenge

Hi guys, I don't understand what is the problem here :(

trial.py
def add(ten , two):
    a = float(10)
    b = float(2)
    return a + b
add( 10 , 2)

2 Answers

Christian Mangeng
Christian Mangeng
15,970 Points

Hi Michele,

the add() function should work for all float number arguments that you pass in, so make sure that you don't use fixed numbers. You can name these arguments a and b, for example (or float1, float2, but the names should match within the function). Using a = float(a) you can convert the passed in argument a to a float number (the same for b). If this conversion is not possible, it means that a and/or b are not float numbers (so, it checks if a and b are float numbers). You don't need to call the function at the end.

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

Thx so much Christian :)