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

Harwood Jones
Harwood Jones
1,377 Points

Defining the function

I'm not sure if I'm way off or not. Am I defining correctly?

squaring.py
import math

def square(number)
    return number * number

number = int(input())

EDIT woops sorry, didn't see the second step.

There's no need to import math in this challenge. Also the challenge asks you to assign the output of your function to "result"

you only need the following:

def square(number):
    return number * number

result = square(3)

2 Answers

def square(TheNumber):
    return number * number

number = int(input("please insert a number"  ))
the_ancear = square(number)
print("the square root of {} is".format(number),the_ancear)

your missing some dots and the name of the def was the same as the input they need to be different names I also put in some user text and a print statement with a bit of formatting to see what you are doing

You forgot to put the colons after defining the function . def square(number): return number*number There is no need of importing math and using the input method because it is not asked for.

Happy coding