import random import string def generate_password(length): """Cette fonction génère un mot de passe aléatoire d'une longueur donnée en utilisant une combinaison de lettres majuscules, de lettres minuscules, de chiffres et de caractères spéciaux""" #Define a string containing all possible characters all_chars = string.ascii_letters + string.digits + string.punctuation # Generate a password using a random selection of characters password = "".join(random.choice(all_chars) for i in range(length)) return password # Test the function by generating a password of length 16 password = generate_password(16) print(password)