This is an exercise on one of the readings. def password(): n=0 a=str(raw_input("Password:")) b="bob123" if a==b: print "You have successfully logged in" n=0 exit() else: n+1 print "Sorry your password was wrong" if n==3: print "You have been denied access" exit() password() all i wanna know is how do i get it to not print the blank space(runtime error) before the raw_input/"password:"
I figured it out my ordering was wrong if someone knows why the order changed this please explain. I know it fixed it but I still don't understand why? def password(): n=0 while n<3: a=str(raw_input("Password:")) b="bob123" if a==b: print "You have successfully logged in" n=0 exit() else: n=n+1 print "Sorry your password was wrong" if n==3: print "You have been denied access" exit() password()
I'm not sure what you're asking here. There's nothing in the first example that would cause it to print a 'blank space'. The only difference is that one uses a while loop to only allow 3 errrors and the first example does not.
What the heck i ran it severely times yesterday and it kept printing a blank input space before it said 'password:' but now when i try it it's working fine. Thanks anyway.
Join our real-time social learning platform and learn together with your friends!