Closed henrique6696 closed 1 month ago
import random import string
def generate_password(length=12): characters = string.asciiletters + string.digits + string.punctuation password = ''.join(random.choice(characters) for in range(length)) return password
password_length = int(input("Enter the desired password length: ")) password = generate_password(password_length) print("Generated password:", password)
import random import string
def generate_password(length=12): characters = string.asciiletters + string.digits + string.punctuation password = ''.join(random.choice(characters) for in range(length)) return password
Example usage:
password_length = int(input("Enter the desired password length: ")) password = generate_password(password_length) print("Generated password:", password)