: ! marks are driving me crazy because they do not make sense to me.
: this is a simple code provided by a tutorial book i found, can
: someone explain it to me?
while password != "unicorn":
password = input("Password: ")
: according to this, the password would be unicorn, however, doesnt
: the exclamation point before the equal sign make password not equal
: to unicorn? This confuses the hell out of me
Simply put that code states the following:
while the password entered is not "unicorn"
prompt for the password
: As a matter of fact this book gives projects, and some possible
: answers to the project, but doesnt really explain it.
: If someone could break this down for me i would appreciate it
Create your username
name = input("What is your UserName: ")
Create your password
password = input("What is your Password: ")
stuff... declaring variables
print("To lock your computer type lock.")
command = None
input1 = None
input2 = None
while the command entered is not lock
prompt for the user to enter a command
while command != "lock":
command = input("What is your command: ")
Now the system is "locked" so how do you unlock it?
By entering your name and password of course...
while the input1 is not the username you created before
prompt for the correct username
while input1 != name:
input1 = input("What is your username: ")
while the input2 is not the password that you made
prompt for the correct password
while input2 != password:
input2 = input("What is your password: ")
print("Welcome back to your system!")
: What does None mean?
None means none. Nothing.
: and also what are the exclamations doing.
keeping you in a while loop until the correct information is entered.
: Why is command even there?
command is there so that you can type in the command "lock"
I would imagine that it could be expanded to allow for you to have other commands, but that is the only role it plays here.
: so lost.