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
def square(number):
    return (number*number)

number = float(input(""))


2 Answers

Mark Chesney
Mark Chesney
11,247 Points

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,845 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.