Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import getpass
- def password():
- login = {'name': ['Josh', 'Ben'],
- 'password': ['Friday', 'Rock', 'Eagle']}
- #userpass = ['Friday']
- tries = 0
- while tries <= 3:
- name = raw_input('Please enter your username: ')
- print
- password = getpass.getpass("Please enter your password: ")
- tries = tries + 1
- if tries == 3:
- print "You had too many attempts"
- break
- else:
- x = str(name)
- b = str(password)
- if x in login['name'] and b in login['password']:
- print
- print "Thank you for logging in", x + '.', "Have a nice day."
- break
- else:
- attempt = (3 - tries)
- print
- print "Sorry, your username or password is incorrect, please try again.", attempt, "attempts remaining"
- print
- continue
- def main():
- print "Welcome to the test password program"
- time.sleep(2)
- print "Please enter your name and password"
- print
- print
- password()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement