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

Creating a function

What could be wrong with code? Its giving me EOF error

squaring.py
def square(number):
    return number * number
your_number=int(input("Enter your number: "))
squared_number = square(your_number)
print("The square of your number is {}".format(squared_number))

1 Answer

boi
boi
8,669 Points

I ran your code 👇

def square(number):
    return number * number
your_number=int(input("Enter your number: "))
squared_number = square(your_number)
print("The square of your number is {}".format(squared_number))

It gives me no error, make sure you save your changes before running it again

NOTE: since, Its a challenge task make sure you don't add something extra, It's giving you an EOF error because you have added extra lines of code, remove them to solve the error.

def square(number):  👈#This is enough to solve the challenge
    return number * number  👈#This is enough to solve the challenge
your_number=int(input("Enter your number: "))  👈#Extra line of code, remove it for the challenge task
squared_number = square(your_number)  👈#Extra line of code, remove it for the challenge task
print("The square of your number is {}".format(squared_number))  👈#Extra line of code, remove it for the challenge task

Thank You Very Much Boi