-
Notifications
You must be signed in to change notification settings - Fork 0
/
PasswordValidation
47 lines (33 loc) · 1.65 KB
/
PasswordValidation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
print('\t\t\t\tCreate new account')
user_name = input('Please enter your email. This will be your username: ')
# Password input from the user
user_password = input("Please enter a strong password for your account creation: ")
# Defining function to make sure the password meets the minimum and maximum required lengths.
def length(user_password):
if len(user_password) < 6 or len(user_password) > 15:
return False
return True
# Defining function to verify password doesn't contain a space.
def includes_space(user_password):
if ' ' in user_password:
# ' ' is to check for space.
return True
return False
# Defining function to make sure password contain at least one digit and one letter.
def includes_digit_and_alpha(user_password):
# Verify length of password is acceptable.
if length(user_password) is False:
return "The length of your password should be greater than 6 and less than 15"
# Verify if it contains a space.
elif includes_space(user_password):
return "Your password must not contain any spaces."
# Check if the input is only letters.
elif user_password.isalpha():
return "Your password is missing at least one digit."
# Check if the input is only numbers.
elif user_password.isdigit():
return "Your password is missing at least one letter."
# If the password meets all requirements, then the password is secure.
return "Your password is secure, and your account has been successfully created! Please go back to the login page to access your account."
# calling function of password to validate it
print(includes_digit_and_alpha(user_password))