Generation

generate functionTue, 13 Dec 2022

create a password verification function. The verification conditions are: the length should be bigger than 6; should contain at least one digit, but it cannot consist of just digits; if the password is longer than 9 - previous rule (about one digit), is not required. Input: A string. Output: A bool. Examples: assert is_acceptable_password("short") == False assert is_acceptable_password("short54") == True assert is_acceptable_password("muchlonger") == True assert is_acceptable_password("ashort") == False

def is_acceptable_password(password: str) -> bool: if len(password) > 6: if len(password) > 9: return True if password.isdigit(): return False else: return True else: return False

Questions about programming?Chat with your personal AI assistant