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

Brian Steyer
Brian Steyer
9,026 Points

Where can i find an example of how to assign a specific variable to square the integer in this function? Thanks!

Are there more reference points where I can look to ensure the formatting and syntax of my code are on target? Thanks!

Brian

squaring.py
def square(number):
    number = (number**)

2 Answers

Antonio De Rose
Antonio De Rose
20,885 Points
def square(number):
    number = (number**)

# 3 errors
# 1, you've been asked to return, so dont assign to number, use return
# 2, syntax error, take off the parenthesis, surrounded by the number**
# 3, square is write like, square**2 or simply square * square
Philip Schultz
Philip Schultz
11,437 Points

Hey, You actually don't have to worry about assigning the value to a variable within the function, just return it. For task 1 of 2 it wants you to simply make a function that accepts a number and return the number squared. Like so,

def square(number):
    return number**2

For task 2 of 2, it wants you to call the function, give it an argument of 3, then store the result in a variable called result.

result = square(3)