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

How do I call a new function and pass it to argument 3? and create a new variable named result to store the value from?

Question: In creating a new square method, I’m supposed to call a new function and pass it the argument 3 and create a new variable named result to store the value from the function call.

Maybe it’s the way the question is worded, but I don’t understand how to solve the following code:

def square(number): number = number * number return number

total_amount = square (5)

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

result = number(5)

2 Answers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Ovava, you are very close!

You correctly defined the funtion square and passed it the parameter number. Next time when you will call this function you can pass it a random number like 3 (second challenge, you passed 5 instead of 3). This number should be multiplied by itself and the result will be returned. You dont need to write result in the return statement. Result is the variable name that will store the returned value after you used the square function.

Does the code below make sense to you?

def square(number): 
    return number * number

result = square(3)

Ahhh.. that makes sense. I thought passing it to 3, was saying to pass the result to line 3 of "return" (not the actual number 3).

Thank you for your help Grigorji!

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Ha Ha, this is a cool mistake to make :))) Keep coding Ovava! We all make mistakes and learn from it ... keep on posting questions here ...