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

Aleksandra Ivanova
Aleksandra Ivanova
279 Points

Storing functions

I do not really understand why for do I store the value here and, basically, what is wrong in the solution

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

1 Answer

Philip Schultz
Philip Schultz
11,437 Points

Hey, This challenge is asking for two parts. The first part (task 1 of 2) Is asking you to make a function called 'square'. This function will have one parameter called 'number', then it will return the square of that number. see code below.

def square(number):
    return number**2 
# NOTE: return number**2 - is how you raise to the power of 2. (if you wanted you could just return number * number)

Task 2 of 2, is asking you to simply call the function and to give it the argument of '3', then store the result in a variable called 'result'.

result = square(3)