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

I'm stumped

I feel like I'm missing something basic here but just overlooking it, also do I always import math?

squaring.py
import math 

def square(number):
    number = (input("Enter a number:   "))
    return  (number*number) 

2 Answers

It depends on what part of the challenge you are on. If you are on the first part:

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

You only have to import math if you are going to use one of the functions in the math class (i.e. ceil, floor, or sqrt), not to perform simple arithmetic.

Hope this helps!

Simon Coates
Simon Coates
8,377 Points

I don't know python, but you seem to be trying to overwrite the parameter you're meant to use. For part 1, it seems to accept:

def square(number):
    return  number*number