# You can set your own rules
def check_password_strength(password):
length = len(password)
has_lower = False
has_upper = False
has_digit = False
special_char = False
lowuppdig = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
for char in password:
if char.islower():
has_lower = True
if char.isupper():
has_upper = True
if char.isdigit():
has_digit = True
if char not in lowuppdig:
special_char = True
if has_lower and has_upper and has_digit and special_char and length >= 10:
return 'Strong'
elif (has_lower or has_upper) and special_char and length >= 8:
return 'Medium'
else:
return 'Weak'
passwords = ['aq1o@p9$XM', 'asW!W)(o', 'WSDFK!#Q', 'n*djskq*', 'WE3q#$']
for password in passwords:
print(check_password_strength(password))
'''
run:
Strong
Medium
Medium
Medium
Weak
'''