assert is_strong_password('Passw0rd!') == True
assert is_strong_password('weakpass') == False
assert is_strong_password('NoDigits!') == FalselanguagePython
Write a function that checks whether a password meets minimum strength requirements: at least 8 characters, at least one uppercase letter, at least one digit, and at least one special character from !@#$%^&*.
def is_strong_password(password):
passimport re
def is_strong_password(password):
if len(password) < 8:
return False
if not re.search(r'[A-Z]', password):
return False
if not re.search(r'\d', password):
return False
if not re.search(r'[!@#$%^&*]', password):
return False
return True