Python Python Basics Functions and Looping Create a Function

Liadan Ryland
Liadan Ryland
401 Points

Getting an EOF error, but shouldn't

I'm getting an EOF error on the treehouse site, but when I run this code on my computer using command prompt, it works.

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

number = int(input("What is your favorite number?"))
squared = square(number)
print(squared)
Matthew Mansfield
Matthew Mansfield
800 Points

I've had similar errors with previous code while locally I don't have such issues. I also think you and I are complicating it more than we should.

Simplify your code to just show and it should work.

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

result = square(3)

1 Answer

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi, Liadan Ryland ! I received your request for assistance. It is important when doing these challenges to not do any more than they explicitly ask for. Remember, there is no one over at the other side to put in a number. Rather the code on Treehouse's side is going to run your code and it should execute as expected.

So while code may be functional in your local environment, it does not necessarily mean it will pass the challenge. To advance past step 1 simply erase the last three lines.

Hope this helps! :sparkles:

Liadan Ryland
Liadan Ryland
401 Points

Thank you Jennifer, that's helpful to know!