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: return len(password) > 6 and any(i.isdigit() for i in password) and not any(j.isdigit() for j in password[-9:])

Questions about programming?Chat with your personal AI assistant