python - Why does my string remove multiple characters? -
i've noticed curious phenomenon here. i've instantiated global variable (usrpin), , i'm comparing local variable (c). when input value (in case, 4 zeros), value chopped off, creating string 1 character long. why?
usrpin ... def login(): global usrpin ... c = str(input("enter pin")) print usrpin print str(c) if usrpin == c: mainmenu() else: print "incorrect pin" login() what on earth going on?
in python 2.x input() automatic evaluation. means when do:
input(0.2757) python evaluates float. similarly, in case 0000 evaluated integer , since 4 zeros same 1 zero, chops away. in python 2.x it's recommended use raw_input() safety.
note: raw_input() in python 2.x returns string.

Comments
Post a Comment