[Tutor] how come this doesnt work
Noah Hall
enalicho at gmail.com
Sat Jan 15 03:45:44 CET 2011
> import random
> for x in range(0,1):
> num = random.random()
> print (num)
> m=input('input pass:')
> if m==num:
> print('you entered correctly, proceed')
Your problem lines in the differences in between the types - your num
variable is a float, whereas your m variable is a string. In order to
compare them here, you need to either use the float() function or the
str() function to convert one to a comparable data type, for example -
if m==str(num):
print('you entered correctly, proceed')
Might I also note that your for loop does nothing except run once, and
the 0 is unnecessary.
HTH
More information about the Tutor
mailing list