Generation

generate functionTue, 13 Dec 2022

create a password verification function in one line. The verification conditions are: 1) the length should be bigger than 6; 2) should contain at least one digit. Input: A string. Output: A bool. Examples: assert is_acceptable_password("short") == False assert is_acceptable_password("muchlonger") == False assert is_acceptable_password("ashort") == False assert is_acceptable_password("muchlonger5") == True

def is_acceptable_password(password: str) -> bool: return len(password)>6 and any(char.isdigit() for char in password) is_acceptable_password("muchlonger5")

Questions about programming?Chat with your personal AI assistant