Sorry, I ALWAYS forget to hit 'Reply All'... On Feb 16, 2008 3:18 PM, John Luke <[EMAIL PROTECTED]> wrote:
> I understand *what's* going on, but I don't understand *why* it's > happening. To be more specific, I don't understand why the actual password, > "unicorn", is what it is, even though I set the password to > "foobar"(password = 'foobar'), and later even stated that the password > wasn't "unicorn"(while password != 'unicorn':). Any help would be greatly > appreciated. Thanks! > The "while" loop is saying: get input from the user, and as long as the response does NOT equal "unicorn", keep looping. You can't check the value of a variable that doesn't exist yet, so the line 'password = "foobar" ' merely served to to create/initialize the 'password' variable. Faced with a similar situation, I would have said ' password = "" ' to avoid exactly this sort of confusion. In fact, I would have done something like the following: tmp_str = "" # this creates the variable so we can check against its value later on password = "unicorn" while tmp_str != password: tmp_str =raw_input("Password: ") print "Welcome in" I hope that makes things a bit clearer... -- www.fsrtechnologies.com -- www.fsrtechnologies.com
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor