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

Alexandre Gagarochkine
Alexandre Gagarochkine
426 Points

I need you to make a new function, add. add should take two arguments, add them together, and return the total.

Hi i did task but programm said somethink wrong. Pls exlane me what wrong? Thanks

trial.py
def add (2, 2):
    return 2 + 2
Bapi Roy
Bapi Roy
14,237 Points

def add (x, y): return x + y

1 Answer

Garrett Hughes
seal-mask
.a{fill-rule:evenodd;}techdegree
Garrett Hughes
Python Development Techdegree Student 32,971 Points

Hey Alexandre,

So the challenge asks for two arguments. When TeamTreeHouse tries to check your function by passing in two arguments, it can't because you've already got (2, 2) set. But if I call this:

def add (x, y): 
    return x + y

It can pass in variables, like:

add(2,2) #Calls add and runs it like your function
add(3,5) #Calls add and runs it with 3 and 5
add(5,8) #calls add and runs it with 5 and 8

to check it. Does that make since?