Sep-23-2021, 11:11 PM
Yesterday I posted an alternative but I do not see it now. It can be modified to produce the same output if desired.
#import sys import string def checkPasswordStrength(password): if len(password) <= 6: print("Password must be at least 7 characters") return teststring = "luds" testlist = list(teststring) special_characters = '!@#$%^&*()' for letter in password : if letter.islower() : testlist[0] = 'X' elif letter.isupper() : testlist[1] = 'X' elif letter.isdigit() : testlist[2] = 'X' elif letter in special_characters : testlist[3] = 'X' test = ''.join(testlist) if test == "XXXX": print("Password is valid") return message = "Password is not valid; missing:" if testlist[0] == 'l': message += " lowercase letter "; if testlist[1] == 'u': message += " upper case letter "; if testlist[2] == 'd': message += " digit "; if testlist[3] == 's': message += " special character "; print(message) checkPasswordStrength('Billycash')