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

Python challenge: Create a function...

I tried my best for the ‘square’ part... but where does ‘number’ come in?

squaring.py
def square(squared)
return (square * square)
print(square * 5)

5 Answers

Hi Katrine Guirguis !

The "number" is the parameter that goes into the parenthesis of the function. For example if you want to do a function that adds a number to itself you would write:

def add(number):
    return number + number

so then when you want to call the function, you have to pass in a number as an argument

add(6)

Calling the function with the number argument is basically substituting the "number" parameter with 6 like so:

def add(6)
    return 6 + 6

Hopefully that helps!

Thank you!

But it still says that I have a syntax error....

How do you put number & square together?

Would you do: def square(number): return square * number Multiply 3 return 3 * 3 = 9 print(9)

boi
boi
14,241 Points

Your idea of the word square is totally off-track for this context. The word square, in this context, is referring to the function name. Which is def square(number). Your idea of square (from what I observed) is that square will literally square the number, which is false. Look at this example;

def NOT_SQUARE(parameter):
    return parameter * parameter


>>> NOT_SQUARE(5)
25

The real magic is the Asterisk * symbol NOT the word square. The basic math rule is applied here where the Asterisk is multiplying the number (in this case parameter) by itself. Any number multiplied with itself gives you the square of that number.

If you're still confused, let me know.