+ 2

my code that checks the lenght of input doesn’t compile

def getnumber(): print('Choose a 4-digits number:') return input() def checklenght(number): if len(number) < 4: print ('your number is too short') return False elif len(number) > 4: print('your number is too long!') return False else: return True secretnumber = getnumber() while not checklenght(secretnumber): secretnumber = getnumber() print('Your secret number is ' + secretnumber) ====== The error says EOF when reading line What is the problem? Many thanks

28th Jul 2018, 6:12 AM
Enrico
1 Respuesta
+ 8
You repeatedly try to get input while the length of num is not 4. Due to the limitations of Code Playground, all input has to be received prior to code interpretation. As a result, the interpreter does not receive any additional input when it expects one. It's not a problem with the code, but rather how it executes on Code Playground.
28th Jul 2018, 6:22 AM
Hatsy Rei
Hatsy Rei - avatar