Loop Question

John Gordon gordon at panix.com
Mon Jun 24 15:00:19 EDT 2013


In <mailman.3754.1372100014.3114.python-list at python.org> =?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= <kwpolska at gmail.com> writes:

> > while True:
> >     username = raw_input("Please enter your username: ")
> >     password = raw_input("Please enter your password: ")
> >
> >     if username == "john doe" and password == "fopwpo":
> >         print "Login Successful"
> >         break
> >
> >     else:
> >         print "Please try again"

> You didn't test the code, did you?  Because the code you posted is
> right.

It's right, therefore I did not test it?  I don't understand.

If the code has a bug, please point it out.

> And note that the getpass module is what you should use for that second
> thing in real life, for the security of your users.

I'm sure this is just an exercise for the OP to understand loops.  Security
would be counter-productive.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list