Python Python Basics Functions and Looping Create a Function

I don't understand what they want here, help please

I'm really mixed up and don't know what they want me to do. please help

squaring.py
def square(number):
    return number * number
    return square
function_name(square) = 3
def result():

3 Answers

Eric McKibbin
MOD
Eric McKibbin
Treehouse Moderator 11,441 Points

Hi Hans,

You're a little mixed up with your syntax, but you're on the right track!

To start with, you've created the correct function for part one of the challenge

def square(number):
    return number * number

When they're asking you to "Under the function definition, call your new function and pass it the argument 3." and store it in a result variable, you don't need to use "def" to create your result variable. I'm pretty new to python myself, but I think def is a keyword for defining functions only. Variables can just be created, they don't need a keyword.

You call a function by using its name, followed by the brackets containing any arguments it needs. In this case you're passing it an argument of 3, so you put three in the brackets.

When python runs, it will turn square(3) into whatever your function returns, but we want to store the returned value in a variable, so we just write the variable name, then = square(3)

def square(number):
    return number * number

result = square(3)

Thank you, this was really helpful! Sorry for taking up your time :)

Omar G.
Omar G.
3,619 Points

Thanks for this. It makes sense now!