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 (5*5)

3 Answers

Steven Parker
Steven Parker
231,268 Points

This code always returns 25 (5*5), but it should return the square of the "number" passed as an argument instead.

def square(number): 
   return (number*number)
Filip Grąz
Filip Grąz
282 Points

Hi

I have problem with second task, please tell me what is wrong with my code?

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

result = square(3) 
print(result)
Steven Parker
Steven Parker
231,268 Points

It's impossible to be sure with unformatted code, but I'd guess you have an indentation issue.

Also, never post a question as an "answer" to another one — always start a new, fresh question.

And when posting code, be sure to format it using the instructions from the Markdown Cheatsheet found below the "Add an Answer" area :arrow_heading_down:   Or watch this video.