Strong Password

  • + 0 comments

    Python best solution

    If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions

    def strong_password(n, password: str):
        add_lower = True
        add_upper = True
        add_number = True
        add_special = True
        for letter in password:
            if letter.islower():
                add_lower = False
            if letter.isupper():
                add_upper = False
            if letter.isnumeric():
                add_number = False
            if letter in "!@#$%^&*()-+":
                add_special = False
    
        characters_to_add = 0
        if add_lower:
            characters_to_add += 1
        if add_upper:
            characters_to_add += 1
        if add_number:
            characters_to_add += 1
        if add_special:
            characters_to_add += 1
    
        if len(password) + characters_to_add < 6:
            return 6 - len(password)
    
        return characters_to_add