+ 1
Keep getting an EOFError with this program in Python
I get the error after giving the input once. I want the program to keep running again till the user gets the right number. Here's the code: import random print("X is a random number between 1 & 20") x = random.randint(1,20) if x < 5: print("X is less than 5.") if x > 5: print("X is greater than 5.") if x < 10: print("X is less than 10.") if x > 10: print("X is greater than 10.") if x < 15: print("X is less than 15.") if x > 15: print("X is greater than 15.") answer = 0 while answer != x: answer = int(input("Guess the value of x: ")) if answer != x: print("You're wrong. Try again.\n") print("You're right! Congratz!\n Thank you for playing!")
2 Réponses
+ 4
All inputs must be entered at the beginning of a program on Sololearn.
Try your code on a different IDE and it should work as expected.
+ 1
Yeah, I think you're right. I was confused about this because in the other IDE I used, the code ran perfectly. And SoloLearn does require you to answer the input function first, which can be annoying if you want to provide specific instructions/hints to the user first. Thanks!