From a5bda707b5d6252f5b22d6077081e6cbb00ff151 Mon Sep 17 00:00:00 2001 From: sri443 Date: Thu, 17 Oct 2024 19:21:54 +0530 Subject: [PATCH] Added check for uppercase letter, updated check for lowercase letter and updated print statement --- .../password-validator/PASSWORD_VALIDATOR.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py b/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py index 76dfbef5..f4965be3 100644 --- a/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py +++ b/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py @@ -9,7 +9,7 @@ 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 an uppercase letter and a 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).') @@ -24,9 +24,13 @@ def passwordValidator(): 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): + if not any(i in string.ascii_letters.upper() for i in userPassword): message = 'Invalid Password..your password should contain at least ' - message += 'an uppercase letter and a lowercase letter' + message += 'an uppercase letter' + return message + if not any(i in string.ascii_letters.lower() for i in userPassword): + message = 'Invalid Password..your password should contain at least ' + message += 'a 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' @@ -38,4 +42,4 @@ def passwordValidator(): return 'Valid Password!' my_password = passwordValidator() -print(my_password) \ No newline at end of file +print(my_password)