Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fileTest =open("usernamepassword.txt", "a")#this creates the text file to store relevant information
- print("What is your first name?")
- firstname = input()
- print("What is your surname?")
- surname=input()
- username=surname[0:3]+firstname[0]+str(len(surname))
- fileTest.write(username + "\n")
- #use + to not have spaces
- #checks the password for validation
- import re
- print("Please enter a password: ")
- password=input()
- x = True
- while x:
- if (len(password)<6 or len(password)>12):
- break
- elif not re.search("[a-z]",password):
- break
- elif not re.search("[0-9]",password):
- break
- elif not re.search("[A-Z]",password):
- break
- elif not re.search("[$#@]",password):
- break
- else:
- print("Valid Password")
- x=False
- break
- if x!=password:
- password=input("Not a Valid Password. Please ensure that your password is between 6 and 12 characters and contains at least an Upper Case letter, a number or a special character. Please enter a new password:")
- if x:
- print("Thank you for signing up, your user name is,", username,"and the password is", password)
- fileTest.write(password)
- fileTest.close()
- file = open("usernamepassword.txt")
- text = file.readlines()
- print("Please confirm your username: ")
- username1=input()
- if username1!=text[0]:
- print("This username does not exist")
- while username1!=username:
- username1=input("Please try again:")
- else:
- print("Thank you")
- attempt=0
- flag=0
- while (attempt!=3):
- password1=input("Please confirm password:")
- if password1==password:
- flag=1
- break
- else:
- attempt=attempt+1
- if(attempt==3):
- print("You have reached the maximum number of attempts!")
- while password1!=password:
- password1=input("Please try again:")
- else:
- print("Thank you, your details have been saved and confirmed.")
Add Comment
Please, Sign In to add comment