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

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
14,241 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