Hello tab and welcome to the forums.
When posting code snippets I would suggest to use the code tags [ code] insert code here [/ code] (without spaces) in order to keep the structure.
Are you sure that this is the whole program? Whats
name and
password in the first part? Just curious.
login = "john" (0)
password = "tucker" (0)
logged=2
while logged != 0: (1)
while login != "Phil": (2)
login = raw_input("Login : ") (2)
while password != "McChicken": (3)
password = raw_input("Password: ") (3)
logged = 1
print "Welcome!" (4)
print "To leave type lock " (5)
while logged == 1: (6)
leave = raw_input (">> ") (7)
if leave == "lock": (8)
logged = 0
print "Goodbye!!"
(1): Do the following as long as
logged is different from 0 (which is at this state always the case because
logged was declared with 2).
(2): As long as the entered username is different from
Phil, ask again for the correct username. As soon as
Phil was entered, it goes to (3)
(3): As long as the entered password is different from
McChicken, ask again for the correct password. As soon as
McChicken was entered,
logged is set to 1 and the lines (4) and (5) are printed.
I am not sure why
login and
password at the beginning (0) are declared with different strings than later used, but I assume it is because to demonstrate that if you declare a variable at a later point with something different, the latest declaration/ comparison is valid.
E.g.
user = "tab"
password = "P()§"JND"
user = "tab2"
password = "ooooo"
print "user: " + user #displays user: tab2
print "pass: " + "password #displays pass: ooooo
(6): Do the following as long as
logged is 1, which is at this point always the case, because it was before set to 1.
(7): Store all input done into
leave (7). As soon as
leave stores the string
lock,
logged is set to 0 which results in leaving the while loop (6) (because
logged == 1 is not true anymore).
Hope you understand my explanations.