Strong Password

  • + 1 comment

    This is a great solution!

    You can simplify it further by changing

    [!@#$%^&*()-+] to \W+ which is the regex for Any Non-alphanumeric character

    So you would have...

    count = 0
    cases = [r'[a-z]', r'[A-Z]', r'[\d]', r'\W+']
    for case in cases:
        if not re.search(case, password):
            count += 1
    
    return max(count, 6 - n)