Skip to content

Commit a5bda70

Browse files
authored
Added check for uppercase letter, updated check for lowercase letter and updated print statement
1 parent a328b66 commit a5bda70

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def passwordValidator():
99
print('\nYour password should: ')
1010
print('\t- Have a minimum length of 6;')
1111
print('\t- Have a maximum length of 12;')
12-
print('\t- Contain at least an uppercase letter or a lowercase letter')
12+
print('\t- Contain at least an uppercase letter and a lowercase letter;')
1313
print('\t- Contain at least a number;')
1414
print('\t- Contain at least a special character (such as @,+,£,$,%,*^,etc);')
1515
print('\t- Not contain space(s).')
@@ -24,9 +24,13 @@ def passwordValidator():
2424
if ' ' in userPassword:
2525
message = 'Invalid Password..your password shouldn\'t contain space(s)'
2626
return message
27-
if not any(i in string.ascii_letters for i in userPassword):
27+
if not any(i in string.ascii_letters.upper() for i in userPassword):
2828
message = 'Invalid Password..your password should contain at least '
29-
message += 'an uppercase letter and a lowercase letter'
29+
message += 'an uppercase letter'
30+
return message
31+
if not any(i in string.ascii_letters.lower() for i in userPassword):
32+
message = 'Invalid Password..your password should contain at least '
33+
message += 'a lowercase letter'
3034
return message
3135
if not any(i in string.digits for i in userPassword):
3236
message = 'Invalid Password..your password should contain at least a number'
@@ -38,4 +42,4 @@ def passwordValidator():
3842
return 'Valid Password!'
3943

4044
my_password = passwordValidator()
41-
print(my_password)
45+
print(my_password)

0 commit comments

Comments
 (0)