Welcome to the Treehouse Community
Looking to learn something new?
Matthew Williams3,103 Points
I'm trying to add two functions together but that doesn't seem to be working.
I'm trying to do as they say. I made my add() function and even put in variables within.
one = int(1)
two = int(2)
I'm sure that's how it's done but I'm not getting anything returned to me.
add(one, two): one = int(1) two = int(2)
Jennifer NordellTreehouse Teacher
Hi Matthew! Dinesh is correct. You must add the two numbers coming into the function and then return the sum of the two numbers. Currently, your code contains neither a return statement nor anything that would add the two arguments.
My code will look much like Dinesh's but I will use the parameter names you've chosen. Take a look:
def add(one, two): return one + two
Here we define a function named "add". This function has two parameters named "one" and "two". You may think of parameters as variable declarations that accept a value from another piece of code. These variables are scoped to the function and will cease to exist when the function is done executing. The function returns the sum of whatever one and two are equal to. So if I did this:
The call to the function would send in the 7 and 9 to the add function. The
one parameter would be assigned the value of 7 and the
two parameter would be assigned the value of 9. We would then add the 7 and 9 together and return the result to the piece of code that called it. And because this is inside a