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

acceptable_password_iv   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A is_acceptable_password() 0 8 4
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