Loop Question
rurpy at yahoo.com
rurpy at yahoo.com
Sun Jun 23 19:49:30 EDT 2013
On 06/23/2013 05:18 PM, christhecomic at gmail.com wrote:
> How do I bring users back to beginning of user/password question once they
> fail it? thx
This is not a very good question. There is no context
so we cannot tell if you are talking about a command line
program that prompts for a username and password or a
GUI program with a text box asking for the user/password
or something else. Nor how exactly you go about doing
the asking.
Some code showing what you are trying to do would help
a lot.
I'll guess you're asking about a simple command line
program. Maybe something like the following is what
you want?
while True:
user = input ("User? ").strip()
pw = input ("Password? ").strip()
if check_user (user, pw): break
print ("Hello %s" % user)
check_user() is a function you'll define somewhere that
checks the user and password and returns True if they are
correct and False if not.
Since you didn't say, I'm also assuming you're using
Python 3; for Python 2 the code will be a little
different.
This is a useful guide to asking questions in a way that
makes it easier for people to answer (and thus help
*you* get better, faster answers):
http://www.catb.org/esr/faqs/smart-questions.html
More information about the Python-list
mailing list