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

Spencer Kane
Spencer Kane
234 Points

What is wrong with this?

When ever I test this code it runs smoothly, but when I run it here I get an EOFError

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

number = float(input(""))

print(square(number))

2 Answers

Hi Spencer. Your function was written 100% correctly. Actually, it's your code written after line 2 that causes the error. If you delete those, it will work just fine.

Create a function named square. It should define a single parameter named number. In the body of the function return the square of the value passed in.

Sarat Chandra
Sarat Chandra
4,898 Points

Hi Spencer Kane I think the reason it is throwing error in exercise window is because it is not designed to take input. The ask of that exercise is just to write a function. Try again by removing code out of function.