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 trialAnmol Gulati
13,991 PointsCreate a function named square. It should define a single parameter named number. In the body of the function, return
def square(number)
return number*2
number = 5
square=number*number
print (square)
2 Answers
simon sjöö
2,130 PointsAll you have to do is change "return number*2" to "return number*number"
Steven Parker
231,275 PointsThe 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.
emmanuelagubata
611 Pointsok, I applied it the way you wrote it, but still get error message.
emmanuelagubata
611 Pointsi got this error message: Bummer: AssertionError: 2 != 1 : Uh oh, seems like your math might be off for the argument 1, try again
emmanuelagubata
611 Pointsdo you know what this error message means?
emmanuelagubata
611 PointsSteven, 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
231,275 PointsStart a fresh question where you show your actual code, and we can probably help you figure it out.