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

Python Squaring Exercise : Create a function named square. It should define a single parameter named number.

In the body of the function, return the square of the value that was passed in.

I'm really stuck

squaring.py
import math

def square(number):
    return (squared)

number= int(input("What is the number"))
squared = (number**2)

print(squared)

It gives the right answer but I have no clue what to put on the return section. I've been at this for hours, no clue what to do.

1 Answer

Steven Parker
Steven Parker
230,324 Points

You've got a calculation to create "squared", but it needs to be done inside the function (before "return").

Also, you won't need to "input" anything for this challenge.

Thank You! that helped

Steven Parker i know you already answered but i really do not understand can you break it down some more please?

Steven Parker
Steven Parker
230,324 Points

Coby, it's just that all code in a function must be indented more than the "def" line. And since "return" ends the function, it must be the last thing done.