+ 1

why this code don't work?

import random import time value = '0' pas = '0' x = 1 pas = input('eneter a password: ') while( x == 1): print(value) time.sleep(0.5) value = random.randint(1, 9) if value == pas: break

13th Feb 2019, 7:59 AM
OneEyeGod
OneEyeGod - avatar
1 Answer
+ 2
the function input() returns a string. that means that the variable 'pas' holds a string. the method randint() returns an int. that means that 'value' holds an int. when you compare: if value == pas that will be never true bacause of the above. you should make 'pas' an int: pas = int(input('enter an integer:'))
13th Feb 2019, 8:35 AM
Ulisses Cruz
Ulisses Cruz - avatar