Python Python Basics Functions and Looping Create a Function

challenge task 2 of 2

squaring.py
def square (number):
    return number * number
result = square ("number")
print(result)

no, sure what i am doing wrong ?

1 Answer

Ryan Groom
Ryan Groom
17,506 Points

Christian Persaudmata So your first line is defining the function and passing a parameter of "number" into the function. The second line is returning the parameter "number" and multiplying it by itself, so whatever you pass into the function it will be multiplied by itself and returned to the function. Your third line is where your issue lies. Your third line is calling the function and storing its value in the variable "result". The problem is that you are trying to pass the string "number" into the function. So the function is taking the string "number" and trying to multiply it by itself and return that value to you. What you want is to actually pass a numeric value into the function and store that result into the variable "result". So your solution would be to pass a number into the function on line three: for example a solution would to be to replace it with "result = square (3)". Hope this helps!