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

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)