Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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 M
Eric M
11,546 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 :)

Thanks for this. It makes sense now!