“Change the name of the function” means actually changing the word “two” and the word “three” on the wording of that function definition to the word “x” and the word “y” (and later changing the numbers within the function). So the code in the terminal will look like:
As to changing of functions names in general, I played around a little and tried to use what @terarockstar09318 mentioned, but got a syntax error. What I could do was create another function and define it as the old mult_x_add_y():
The bananas() function seems to use/pull the code within mult_x_add_y() without me having to write it again. However that looks more like I created a different function, with a different name, that does the same thing as mult_x_add_y() rather than actually changing its name (as we have done on the exercise, manually replacing the “two” and “three” by “x” and “y” on the first function definition).
Bear in mind for the lesson this issue refers to, renaming the function is literally changing the name of the function in the code so just edit the line as per the previous reply-
More generally in Python there may be a reason we wish to change the name of a function after it has been bound to a reference and it is not practical and likely to throw up errors if we changed the name of the function in the code itself. Say for example we used a function imported from a module (changing the name in the module is a very bad idea). Best practice for for the given case would be from module import function as name but for other purposes like backwards compatability (there are proper ways to deal with backwards compatability references too) we may wish to just add a new reference to the same object.
@terarockstar09318 is simply adding a new name to the original function (it alters nothing about the object itself). This is perfectly reasonable and the syntax shoulld be straightforward, I’m not certain what error you received.
def mult_x_add_y(number, x, y):
print(number*x + y)
mult_x_add_y(1, 3, 1)
bananas = mult_x_add_y # Just binds a new name to the same object
bananas(1, 3, 1)
print(mult_x_add_y is bananas) # Are these bound to the same object?
Regarding your code (I changed the name of the variables so it was more obvious that the arguments you pass to bananas are then subsequently passed to mult_x_add_y, it doesn’t actually change anything) it’s the same as-