Loop Question

John Gordon gordon at panix.com
Mon Jun 24 14:42:43 EDT 2013


In <e41ce3a3-c8cb-4cfc-ba86-462f40f322fc at googlegroups.com> christhecomic at gmail.com writes:

> On Sunday, June 23, 2013 6:18:35 PM UTC-5, christ... at gmail.com wrote:
> > How do I bring users back to beginning of user/password question once they
> > 
> > fail it? thx

> Can't seem to get this to cooperate...where does the while statement belong?

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"

-- 
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