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

please am frustrated by the challenge to create function, am failing over and over, kindly assist!

Create a function named square...

def split_check(square):
    return square*2

3 Answers

Maxwell Newberry
Maxwell Newberry
7,693 Points

In your return statement you are simply multiplying the argument by 2, when the challenge is asking for you to square the number. Meaning, multiply the passed argument by itself, not by 2.

def square(number):
    return  number * number

Don't be frustrated! It takes time and you're definitely on the right track. :)

Owen Bell
Owen Bell
8,060 Points

To add to this, you can define the index that you should raise your base to (i.e. how many times you should be multiplying the parameter by itself) with a double-asterisk:

def square (number):
    return number ** 2;

Which is only slightly more streamlined in this particular case, but is much more useful for running higher-order calculations or functions where the index should be an argument to be provided or where it varies over time.

David Garcia
.a{fill-rule:evenodd;}techdegree seal-36
David Garcia
Python Development Techdegree Graduate 11,254 Points

Tip: read the questions very carefully they tell you how to do said problem but you must come up with the logic...

1: first you need to create a defined function called 'square' that takes an argument called 'number' example: def example(argument):

2: then create the value of said argument called number inside defined function and tell it what it means example: def example(argument): argument = argument * argument

3: then return said value as soo....:

def example(argument): argument = argument * argument return argument

if you don't understand this, here's the answer. I'd advise you to look at the answer and study from it and remember what it does also remember there's different ways of doing problems.

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

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