# FAQ: Introduction to Functions - Multiple Parameters

This community-built FAQ covers the “Multiple Parameters” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply ( ) below!

Agree with a comment or answer? Like ( ) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’m having issues too, only I went with this. Not running though. Could sure use some help. Defining a function only gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code.

Once the basic structure of a function is finalized, you can execute it by calling the function

you never call the functions, thus the functions never execute

@balint2, you call the functions, but the function calls are nested inside the functions. The function calls should be outside/after the function

Hi, I still don’t understand why “mult_x_add_y(5,2,3)” doesn’t work…

Edit: Never mind, I worked it out. I wasn’t paying attention to indentation…

Hi, after renaming the function to `mult_x_add_y` And now, add `x` and `y` as parameters of the function, after `number` .

Maybe, it would help to precise that the function has 3 ( THREE ) parameters : 1 - number, 2 - x and 3 - y

this kind of precision would help understand the change in the numbers of the parameters, and ease the execution of the following instructions.
BR
Vince

We cannot evaluate values in the parameter list.

``````#wrong
def foo(1 - number, 2 - x and 3 - y):
pass

foo(a, b, c)

#right
def foo(number, x, y):
pass

foo(1 - a, 2 - b, 3 - c)
``````

The latter example evaluates the arguments and passes the resulting values.

Yes. You are right. And I agree with you.The 3 parameters remark deals with the way the question is worded in the course. I would have spent less time trying to solve this simple question if it was written more clearly : Now add two parameters to the parameter number. Now, the function have 3 parameters. That’s a way to ease the study and is more related to the teachers team. It is a matter of clarity.

1 Like

The function mult_two_add_three takes a number, multiplies it by two and adds three. We want to make this more flexible. First, change the name of the function to mult_x_add_y .

Sure, I’d love to. But how do I change the name of a function? Kinda confused here.

ETA: I got it now. It wanted me to literally change the name of the function in the code, which had been empty/overwritten with stuff from previous sections. Had to reset the section.

How do I rename a function?

when you define a function:

``````def example():
``````

you can rename the function at the definition:

``````def rename():
``````

I don’t get it either. I think my code looks the same as the answer, but it doesn’t work!!

def mult_x_add_y(number, x, y):
print(number*x + y)
result = mult_x_add_y(1, 3, 1)
print(result)

What is wrong in this set of code?
I thought I would get the output as :
4
4
But i got it as :
4
None
Why did this happen?

Saharshjain, make sure to use the </> icon to post your code properly formatted, so that we can read it easily, and it is actually Python code. I need to guess a bit about the indentation. Is this it?

``````def mult_x_add_y(number, x, y):
print(number*x + y)
result = mult_x_add_y(1, 3, 1)
print(result)
``````

Let us follow the code. The Python interpreter goes down the left-most indentation level.
First it sees the function declaration `def mult_x_add_y():`. It puts the function in memory, keeping the function name for reference.

Next, it gets to the line `result = mult_x_add_y(1, 3, 1)` That is an assignment statement (because it has the assignment operator, =). Every assignment statement says, "first, evaluate the expression on the right, then assign the returned value to the variable on the left.

So, the expression on the right is the original function, along with the arguments (1, 3, 1). The function is called, and it is executed: It has one line, `print(number*x + y)` and we know because of the order of the arguments that number = 1, x = 3, and y = 1. The expression within the print() function parentheses evaluates to 4, so you see 4 printed on your screen.

Now, here is the key: The function has executed, and the next step is to assign its returned value to the variable result. What is the returned value?

==> There is no returned value specified for this function, and in Python, if a function has no return value specifies, it returns None.

So the value None is assigned to the variable result.

The next (and final) line is `print(result)`. When this is executed, None is printed, onscreen, as you see.

Bottom line:

• We print() values that we want to see onscreen
• We return values that Python needs to use, possibly to assign to a variable, or pass to another function.
1 Like

Okay…I now know what went wrong. Now,
I tried to get the out put as :
4
4
By adding a return statement at the end of the function. So the code is :

``````def mult_x_add_y(number, x, y):
print(number*x + y)
return mult_x_add_y(1, 3, 1)
result = mult_x_add_y(1, 3, 1)
print(result)
``````

When I executed this I got an infinity loop having an output of 4s
What should i do now?
What went wrong?

Don’t forget to use the </> icon to properly display code. Is this it?

``````def mult_x_add_y(number, x, y):
print(number*x + y)
return mult_x_add_y(1, 3, 1)
result = mult_x_add_y(1, 3, 1)
print(result)
``````

Notice that when return is called, the function runs again, that is, the function calls itself.
That is called recursion, and if you delve further into computer science, you will see that it can be a very useful technique. But at this stage, it is best avoided, for it is nearly a certain way to ensure an infinite loop.

(Unless you are purposely using recursion - which should not be the case here), return a value or an expression that produces a value, not the function that contains the return statement…

Done…

``````def mult_x_add_y(number, x, y):
new_number = number * x + y
return new_number
new_number = mult_x_add_y(1, 3, 1)
print(new_number)
``````

I got the answer as 4 at last
Thanks so much patrick. But I still can’t understand how to properly display code I got it…“stetim94” helped me

From what (I think) I understand, when you call the function the code should not be indented

i had the same issue until i figured that there’s an intend between the comma and 2 also between comma and 3 in the function call