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!
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
Tsholofelo Goabaone Kenathetswe2,469 Points
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
Maxwell Newberry7,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. :)
David GarciaPython 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
Rutendo Chaurura6,809 Points
def square(number): number=number*number return number
Owen Bell8,059 Points
Owen Bell8,059 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:
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.