Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def existingUser():
- for i in range(5):
- existingUsername = input("What is your user name?")
- if existingUsername in open('logins.txt').read():
- with open("logins.txt", "r") as myFile:
- for num, line in enumerate(myFile, 1):
- if existingUsername in line:
- passwordLine = num + 1
- passwordAttempt = input("What is your password?")
- loginsList=myFile.readlines()
- passwordText = loginsList[passwordLine]
- if passwordText == passwordAttempt:
- print("That is correct")
- quizSelection()
- break
- else:
- print("That doesn't seem to match. Please try again")
- def existingUser(max_tries=3):
- with open('logins.txt') as fp:
- lines = [line.strip() for line in fp.readlines()]
- logins = dict(zip(lines[::2], lines[1::2]))
- for n in range(max_tries):
- username = input("What is your user name? ")
- password = input("What is you password? ")
- if logins.get(username) == password:
- print("That is correct")
- return username
- else:
- print("try again")
- print("Too many tries")
- return False
- if existingUser():
- quizSelection()
Add Comment
Please, Sign In to add comment