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 to store a returned value of a function in a new variable

squaring.py
def square(number):
    return number *number
print(square(2))
result=repeat_square(2)

print(result)

2 Answers

Tabatha Trahan
Tabatha Trahan
21,422 Points

The code challenges are pretty picky, so first off I would suggest getting rid of the 2 print statements, and then take a closer look at your result variable that is to hold the value of the result of calling the square function. Make sure you use the correct function name (what you used to define the function) when you call the function. If you defined the function name as square, use the name square when calling the function- repeat_square is not defined in the code above. I hope this helps.

Christopher Buckhout
seal-mask
.a{fill-rule:evenodd;}techdegree
Christopher Buckhout
Python Development Techdegree Student 786 Points

Hi all, I'm having difficulty on this Code Challenge as well: "Under the function definition, call your new function and pass it the argument 3. Since your square function returns a value, create a new variable named result to store the value from the function call".

What is meant by passing it the argument 3? I'm also confused over the specific "value" to store from the function call square.