Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Create a Function

I'm totally lost on what to do here.

def number(square)
retun square x square

1 Answer

Brandon White
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

Hi Jeremy,

Your logic is spot on, but you have some syntactical issues in your code.

The syntax for defining a function in python is as follows:

def function_name(parameter):
    # the code inside the function
    # must be indented so that python understands
    # it's a part of the function
    return "some value"

You'll need to add a set of colons after your function name. Then you'll need to indent your return statement (also you've left the second "r" out of return).

Finally, x does not mean multiplication in python. There is a specific operator used in python to multiple values, and it is called the multiplication operator. The multiplication operator is the following character: *

So make those changes, and you'll be all set.

Katrine Guirguis
Katrine Guirguis
2,587 Points

I did it and it worked, thanks!