Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, time
- print("Tips for creating a good password:",\
- "\n\t----1.Use a combination of uppercase and lowercase letters.\n",\
- "\n\t----2.Use numbers\n",\
- "\n\t----3.Use special characters like '!£$%^&'.\n",\
- "\n\t----Remember that your password has to be between 8 and 14 characters.\n",\
- "=" * 75
- )
- time.sleep(1)
- def set_userName():
- global userName
- print("\n\t----Enter your username")
- userName = input("\n\t\tUsername: ")
- print("\n\t----Your username was saved.\n")
- set_userQuestions()
- def set_userQuestions():
- global secQuestions, ansQuestions, userQuestions
- print("=" * 75)
- secQuestions = ["What is the title of your favourite movie?",\
- "Who is your favourite music artist?",\
- "What is your mother's maiden name?"]
- userQuestions = []
- for x in range(0, len(secQuestions)):
- print("\t\t", secQuestions[x])
- ansQuestions = input("\n\t\tAnswer: ")
- userQuestions.append(ansQuestions)
- print("=" * 25)
- set_userPassword()
- def set_userPassword():
- global userName, userPassword
- print("\n\t----Create your password")
- userPassword = input("\n\t\tPassword: ")
- print("\n\t----Confirm your password")
- confirmPassword = input("\n\t\tConfirmation: ")
- if confirmPassword == userPassword and (len(userPassword) >= 8 and len(userPassword) <= 14):
- print("\n\t----Your password was saved.")
- user_login(userName, userPassword)
- elif (confirmPassword == userPassword) and not (len(userPassword) >= 8 and len(userPassword) <= 14):
- print("\n\t----Your password is too short or too long. Remember it has to be between 8 and 14 characters.")
- set_userPassword()
- else:
- print("\n\t----Your passwords don't match.")
- time.sleep(1)
- set_userPassword()
- def user_login(userName, userPassword):
- print("=" * 75)
- tries = 0
- for tries in range(0, 2):
- loginUsername = input("\n\t\tEnter your username: ")
- loginPassword = input("\n\t\tEnter your password: ")
- if loginPassword == userPassword and loginUsername == userName:
- time.sleep(0.5)
- detail_registration()
- else:
- print("\n\t----Username or password wrong, check again")
- tries +=1
- if tries == 2:
- print("\n\t----Your account has been blocked. You can recover your password by answering one of the available security questions")
- security_questions(tries)
- def security_questions(tries):
- global secQuestions, ansQuestions
- print("=" * 75)
- secNo = random.randint(1, 3)
- for i in range(1, 3):
- if secNo == i:
- print(secQuestions[i])
- checkQuestion = input("Answer: ")
- if checkQuestion == ansQuestions:
- detail_registration()
- else:
- print("\n\t----Your account has been blocked, call the customer service to retreive it.")
- def detail_registration():
- global userName, userQuestions, userPassword
- print("=" * 75)
- print("\t----Welcome\n")
- detailDict = {
- "username": userName,
- "password": userPassword,
- "question_1": userQuestions[0],
- "question_2": userQuestions[1],
- "question_3": userQuestions[2]
- }
- print("\t\tUsername: ", "".join(detailDict["username"]),\
- "\n\n\t\tPassword: ", "".join(detailDict["password"]),\
- "\n\n\t\tWhat is the title of your favourite movie? ", "".join(detailDict["question_1"]),\
- "\n\n\t\tWho is your favourite artist? ", "".join(detailDict["question_2"]),\
- "\n\n\t\tWhat is your mother's maiden name? ", "".join(detailDict["question_3"]))
- set_userName()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement