Make a flowchart, by hand, on paper of what this program does.  That should 
help explain the why.

Basically, after 3 attempts, your "while" loop becomes an infinte loop.  Once 
you are over the count, the user is never prompted for
another password, so the password remains not equal to "unicorn" until the end 
of time.

Thanks,
Ryan 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Monday, April 11, 2005 2:55 PM
To: tutor@python.org
Subject: [Tutor] Cell Bio Newbie Here

Hey all,

Sorry for the bother, thanks for the help.

I'm trying to write a password guessing program to keep track of
how many times the user has entered the password wrong.
If it is more than 3 times, print ``That must have been complicated.''

Following is what I got.  If I type "unicorn" it goes straight to "welcome 
in." Great.  But after my third mistake, it just loops in "That must have 
been complicated."

I'd like for someone to tell me "why" i screwed up.  Not to just fix it.

Thank you so much in advance.  And to give you a little smile for a Monday, 
I've been working on this for days....argh



#first of all, why does this have to be here?
password="foobar"

count=3
current_count=0

while password !="unicorn":
     if current_count<count:
         password=raw_input("Password:")
         current_count=current_count+1
     else:
         print "That must have been complicated"


print "Welcome in"
Best,

Gary



Gary Laevsky, Ph.D.
Keck Facility Manager, CenSSIS
Northeastern University
302 Stearns
360 Huntington Ave.
Boston, MA 02115
voice(617) 373 - 2589<br>
fax(617) 373 - 7783<br><br>

http://www.censsis.neu.edu

http://www.ece.neu.edu/groups/osl

http://www.keck3dfm.neu.edu

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to