I am learning Python from 3 different books. Beginning Python From Novice To Professional, Wrox - Beginning Python, and finally Byte of Python.
Here is a three trial on a program that would authenticate a user name and a password to allow anyone permission to enter (enter where i don't know, it is just something i tried to do as a first program)
Code: Select all
Usr = ["mark" , "foo" , "boo"]
Pas = ["12345"]
Printable = "Welcome! Have a nice day"
while True:
User = raw_input("Username: ")
Pass = raw_input("Password: ")
if User == Usr and Pass == Pas:
print Printable
Break
else:
print "Access denied, Please try again"
Code: Select all
Usr = ["mark" , "foo" , "boo"]
Pas = ["12345"]
Printable = "Welcome! Have a nice day"
while True:
User = raw_input("Username: ")
Pass = raw_input("Password: ")
if User == Usr = True and Pass == Pas = True:
print Printable
Break
else:
print "Access denied, Please try again"
Code: Select all
Usr = ["mark" , "foo" , "boo"]
Pas = ["12345"]
Printable = "Welcome! Have a nice day"
while True:
User = raw_input("Username: ")
Pass = raw_input("Password: ")
if User in Usr = True and Pass in Pas = True:
print Printable
Break
else:
print "Access denied, Please try again"
Code: Select all
Usr = ["mark" , "foo" , "boo"]
Pas = ["12345"]
while True:
User = raw_input("Username: ")
Pass = raw_input("Password: ")
if User in Usr = True
if Pass in Pas = True:
print "Welcome! Have a nice day"
Break
else:
print "Access denied, Please try again"
As you can see different combinations doesn't do any good. I even have another file using a dictionary and a tuple. Still nothing. I know it is the While loop and i tried to change the condition but still...
Thanks in advance