Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ def passwordValidator():
print('\nYour password should: ')
print('\t- Have a minimum length of 6;')
print('\t- Have a maximum length of 12;')
print('\t- Contain at least an uppercase letter or a lowercase letter')
print('\t- Contain at least one uppercase letter and one lowercase letter')
print('\t- Contain at least a number;')
print('\t- Contain at least a special character (such as @,+,£,$,%,*^,etc);')
print('\t- Not contain space(s).')
# get user's password
# get user's password
userPassword = input('\nEnter a valid password: ').strip()
# check if user's password conforms
# to the rules above
# check if user's password conforms
# to the rules above
if not(6 <= len(userPassword) <= 12):
message = 'Invalid Password..your password should have a minimum '
message += 'length of 6 and a maximum length of 12'
return message
if ' ' in userPassword:
message = 'Invalid Password..your password shouldn\'t contain space(s)'
return message
if not any(i in string.ascii_letters for i in userPassword):
message = 'Invalid Password..your password should contain at least '
message += 'an uppercase letter and a lowercase letter'
if not any(i in string.ascii_uppercase for i in userPassword):
message = 'Invalid Password..your password should contain at least one uppercase letter'
return message
if not any(i in string.ascii_lowercase for i in userPassword):
message = 'Invalid Password..your password should contain at least one lowercase letter'
return message
if not any(i in string.digits for i in userPassword):
message = 'Invalid Password..your password should contain at least a number'
Expand Down
Loading