| Total Complexity | 4 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 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 |