Passed
Push — master ( be414c...be1b15 )
by Ken M.
01:42
created

acceptable_password_iv.is_acceptable_password()   A

Complexity

Conditions 4

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
from re import search
2
3
4
def is_acceptable_password(password: str) -> bool:
5
    if len(password) < 6:
6
        return False
7
    elif len(password) > 9:
8
        return True
9
    elif len(password) > 6:
10
        return bool(search(r'\d', password)) and bool(search(r'\D', password))
11
    return False
12
13
14
if __name__ == "__main__":
15
    # These "asserts" are used for self-checking and not for an auto-testing
16
    assert is_acceptable_password("short") == False
17
    assert is_acceptable_password("short54") == True
18
    assert is_acceptable_password("muchlonger") == True
19
    assert is_acceptable_password("ashort") == False
20
    assert is_acceptable_password("muchlonger5") == True
21
    assert is_acceptable_password("sh5") == False
22
    assert is_acceptable_password("1234567") == False
23
    assert is_acceptable_password("12345678910") == True
24
    print("Coding complete? Click 'Check' to earn cool rewards!")
25