@@ -9,24 +9,26 @@ def passwordValidator():
99 print ('\n Your 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 one uppercase letter and one 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).' )
16- # get user's password
16+ # get user's password
1717 userPassword = input ('\n Enter a valid password: ' ).strip ()
18- # check if user's password conforms
19- # to the rules above
18+ # check if user's password conforms
19+ # to the rules above
2020 if not (6 <= len (userPassword ) <= 12 ):
2121 message = 'Invalid Password..your password should have a minimum '
2222 message += 'length of 6 and a maximum length of 12'
2323 return message
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 ):
28- message = 'Invalid Password..your password should contain at least '
29- message += 'an uppercase letter and a lowercase letter'
27+ if not any (i in string .ascii_uppercase for i in userPassword ):
28+ message = 'Invalid Password..your password should contain at least one uppercase letter'
29+ return message
30+ if not any (i in string .ascii_lowercase for i in userPassword ):
31+ message = 'Invalid Password..your password should contain at least one lowercase letter'
3032 return message
3133 if not any (i in string .digits for i in userPassword ):
3234 message = 'Invalid Password..your password should contain at least a number'
0 commit comments