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

Create a function named square. It should define a single parameter named number. In the body of the function, return

squaring.py
def square(number)
return number*2
number = 5
square=number*number
print (square)

2 Answers

All you have to do is change "return number*2" to "return number*number"

Steven Parker
Steven Parker
231,236 Points

The value being returned here is the number times 2 instead of the number squared. The exponent operator has two asterisks ("**"), or you can multiply the number by itself as you did later. And to be considered part of the function, the "return" statement must be indented.

Also, you don't need any of that code following the function for the challenge.

ok, I applied it the way you wrote it, but still get error message.

i got this error message: Bummer: AssertionError: 2 != 1 : Uh oh, seems like your math might be off for the argument 1, try again

do you know what this error message means?

Steven, thank you for the answer, but my script returned the error on the math. If you have a solution to it please post it. thank you.

Steven Parker
Steven Parker
231,236 Points

Start a fresh question where you show your actual code, and we can probably help you figure it out.