From 3167a66c6cb2ebe274c67e7342c06f9442a9ae01 Mon Sep 17 00:00:00 2001 From: Tushar Gupta Date: Wed, 29 Apr 2026 09:29:48 +0000 Subject: [PATCH] Fix: Password validator checks for uppercase letters --- .../password-validator/PASSWORD_VALIDATOR.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py b/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py index 76dfbef5..a3252183 100644 --- a/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py +++ b/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py @@ -9,14 +9,14 @@ 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' @@ -24,9 +24,11 @@ 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): - 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'