-1

I get the following error when I try to execute this code,

Traceback (most recent call last):
  File "c:\dev\tmp\_t636427523447579562.py", line 32, in  tentativa = int(input())
EOFError: EOF when reading a line

import random
import sys

controlo = 0
numero = 134+78



while controlo<3:
    tentativa = int(input())

    if tentativa == numero:
        print("Acertou")
        break
    else:
         controlo +=1
         continue

if controlo == 3:
    print("Falhou")
    sys.exit()



controlo = 0

random_1 = random.randrange(1, 100)
random_2 = random.randrange(1, 100)
soma = random_1 + random_2

while controlo<3:
    tentativa_2 = int(input())

    if tentativa_2 == soma:
         print("Acertou")
         break
    else:
            controlo +=1
            continue

if controlo == 3:
    print("Falhou")
glennsl
  • 28,186
  • 12
  • 57
  • 75

2 Answers2

0

Change of the below line may fix your problem

tentativa = int(input())

read = input()

now you can check here whether 'read' is digit or mix with character add a if condition and check

tentative = int(read)

Abhijit Pritam Dutta
  • 5,521
  • 2
  • 11
  • 17
0

I'm guessing you are using Python 2 here not Python 3 as your tag suggests.

In Python 2 input() waits for the user to enter some text and then tries to execute it. If you press 'Enter' input() will give an EOF error. I assume that is what has happened here as your code works if numbers are entered. I suggest using Python 3 or raw_input() in Python 2. See here for more.

blueenvelope
  • 699
  • 7
  • 15