Codeacademy compiler

Why does this creates an error in codeacademy compiler but runs perfectly fine outside.
num = input("Please enter a number: ")

print(int(num) ** 2)

Traceback (most recent call last):
File “”, line 1, in
num = input("Please enter a number: ")
EOFError: EOF when reading a line

Hello @abhinavbhatia3557794, welcome to the forums!
Can you send a link to the exercise, please? Quite often, the CC terminal isn’t configured to take input from the user, which means that Python will then throw that error (as no input has been given when it should have). I know it isn’t particularly ideal, but one workaround is to just hardcode a value to each variable that would otherwise take input using input()
I was referencing the snippet on this page

As I suspected, CC’s terminal doesn’t allow for user input there (I don’t know why…); to demonstrate the effect they were trying to, run a similar piece of code:

num  = "2" #Because the default type that input returns is a string
print(num ** 2)

Which will also throw a TypeError.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.