help on ultra newbie program please

cybernut cybernut at uswest.net
Wed May 21 12:30:06 EDT 2003


I'm a network admin, but have had an itch to learn programming for a while
and finally started looking at which language to begin with. After reading
for a while it sounded like python was a really good one so I went to
www.python.org and started going through the "A Non-Programmer's Tutorial
for Python" guide by Josh Cogliati. I already have a linux box running that
I am using for this...

I'm kind of stuck on one of the excersizes though and I hate to ask for help
on this because I want to figure it out on my own, but I've wasted too much
time on it. It is basically taking his Password.py code and modifying it so
that it kicks you out if an incorrect password is entered 3 times. Now, I
can get it to kick ya out if 3 bad passwords are entered ,but I cannot get
it to do that and also end it if the correct password is put in. It will
take the correct password and ask for another password again which is
stupid. It seems like I need a loop within a loop, but Im not seeing it.
Anyone able to shed some light on this for me? Maybe Im not cut out for
this, but I wanna give it a good go.

By the way, up to that point in the guide Ive only learned the while loop.
So other advanced programming techniques shouldn't be used unless its just
not possible with the info hes taught so far...

# Waits until a password has been entered.  Use control-C to break out with
out
# the password

#Note that this must not be the password so that the
# while loop runs at least once.
password = "foobar"

#note that != means not equal
while password != "unicorn":
    password = raw_input("Password:")
print "Welcome in"

Thank!







More information about the Python-list mailing list