Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Create a Function

Simon Au
Simon Au
5,508 Points

EOF Error when using input

Currently struggling with this EOF problem. Any guidance would be great!

squaring.py
def square(number):
    return int(number*number)
amount = input('Enter the number')
result = square(amount)

1 Answer

Hi Simon,

If you wrap your input request using int() then this returns a number instead of a string.

I done this myself loads of times and you can't see it for looking at it.

I tend to print out my variables and also the type at each stage so I can check if it's a number etc....

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

amount = int(input('Enter the number '))
result = square(amount)
print(result)