password generator allows you to generate a random password of length n lenpasswordgenerator 8 lenpasswordgeneratorlength16 16 lenpasswordgenerator257 257 lenpasswordgeneratorlength0 0 lenpasswordgenerator1 0 alternative methods charsincl characters that must be in password i how many letters or characters the password length will be password generator full boot with randomnumber randomletters and randomcharacter functions put your code here chars charsincl randomlettersasciiletters i 3 remainder randomnumberdigits i 3 randomcharacterspunctuation i 3 random is a generalised function for letters characters and numbers this will check whether a given password is strong or not the password must be at least as long as the provided minimum length and it must contain at least 1 lowercase letter 1 uppercase letter 1 number and 1 special character isstrongpassword hwea72 true isstrongpassword sh0r1 false isstrongpassword hello123 false isstrongpassword hello1238udfhiaf038fajdvjjf jaiufhkqi1 true isstrongpassword 0 false password generator allows you to generate a random password of length n len password_generator 8 len password_generator length 16 16 len password_generator 257 257 len password_generator length 0 0 len password_generator 1 0 alternative methods chars_incl characters that must be in password i how many letters or characters the password length will be password generator full boot with random_number random_letters and random_character functions put your code here chars chars_incl random_letters ascii_letters i 3 remainder random_number digits i 3 random_characters punctuation i 3 random is a generalised function for letters characters and numbers put your code here put your code here put your code here this will check whether a given password is strong or not the password must be at least as long as the provided minimum length and it must contain at least 1 lowercase letter 1 uppercase letter 1 number and 1 special character is_strong_password hwea7 2 true is_strong_password sh0r1 false is_strong_password hello123 false is_strong_password hello1238udfhiaf038fajdvjjf jaiufhkqi1 true is_strong_password 0 false
import secrets
from random import shuffle
from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation


def password_generator(length: int = 8) -> str:
    
    chars = ascii_letters + digits + punctuation
    return "".join(secrets.choice(chars) for _ in range(length))





def alternative_password_generator(chars_incl: str, i: int) -> str:
    
    
    
    i -= len(chars_incl)
    quotient = i // 3
    remainder = i % 3
    
    
    chars = (
        chars_incl
        + random(ascii_letters, quotient + remainder)
        + random(digits, quotient)
        + random(punctuation, quotient)
    )
    list_of_chars = list(chars)
    shuffle(list_of_chars)
    return "".join(list_of_chars)

    


def random(chars_incl: str, i: int) -> str:
    return "".join(secrets.choice(chars_incl) for _ in range(i))


def random_number(chars_incl, i):
    pass  


def random_letters(chars_incl, i):
    pass  


def random_characters(chars_incl, i):
    pass  


def is_strong_password(password: str, min_length: int = 8) -> bool:
    

    if len(password) < min_length:
        return False

    upper = any(char in ascii_uppercase for char in password)
    lower = any(char in ascii_lowercase for char in password)
    num = any(char in digits for char in password)
    spec_char = any(char in punctuation for char in password)

    return upper and lower and num and spec_char


def main():
    length = int(input("Please indicate the max length of your password: ").strip())
    chars_incl = input(
        "Please indicate the characters that must be in your password: "
    ).strip()
    print("Password generated:", password_generator(length))
    print(
        "Alternative Password generated:",
        alternative_password_generator(chars_incl, length),
    )
    print("[If you are thinking of using this password, You better save it.]")


if __name__ == "__main__":
    main()