7.6 More than one arguement


Please somebody help I don't know what im doing. I have to Define a function called add_function that has 2 parameters x and y and adds them together, and ive got this

m = 5
n = 13
# Add add_function here!

print add_function(m, n)

In Idiots terms please, im not good


You're not an idiot. Some people find coding easier than others, that's all.

Define a function called add_function...

def add_function():

...That has two parameters; x and y...

def add_function(x,y):

and (I'm assuming you need to return the value, not print) return the sum of the two numbers...

return x + y

So the final thing would look like this;

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

(If you needed to print it instead, just replace the code inside the function;

def add_function(x,y):

or call the function with return, and print the returned value;

def add_function(x,y):
  return x + y
print(add_function(1,2)) #prints 3

Do you understand?