[Tutor] Looping

Lloyd Hugh Allen lha2@columbia.edu
Mon, 15 Apr 2002 05:54:14 -0400


The variable "password" is not updated inside the loop. Since password
never changes, you're stuck in an infinite loop.

You want something like

password = raw_input("Password:")
while password != "password"
               print "Wrong Password"
               password = raw_input("Password:")

"Crane, Adam" wrote:
> 
> Ok, I'm a newbie to Python, so please forgive me if this sounds stupid :)
> But I'm not really sure where to send this...
> 
> Is there a way to stop text from looping using while?  For example, if I
> used this in a program, the indented text would loop:
> 
> password = raw_input("Password:")
> while password != "password":
>                print "Wrong Password"
> 
> I still having a lot of reading to do on Python, but this is really bugging
> me.  This is probably really obvious, but any help would be appreciated.
> 
> Thanks,
> Adam
> 
> The contents of this e-mail are intended for the named addressee only. It
> contains information which may be confidential and which may also be
> privileged. Unless you are the named addressee (or authorised to receive for
> the addressee) you may not copy or use it, or disclose it to anyone else. If
> you received it in error please notify us immediately and then destroy it.
> The information, views and comments within this communication are those of
> the sender and not necessarily those of Computer 2000.
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor