How to Password Generator Python Code? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

How to Password Generator Python Code?

import random import string def generate_password(length): """Generate a random password of a given length""" characters = string.ascii_letters + string.digits + string.punctuation password = ''.join(random.choice(characters) for i in range(length)) return password # Example usage password = generate_password(12) print(password)

19th Apr 2023, 11:50 AM
Muhammad Nouman Ali
Muhammad Nouman Ali - avatar
1 Réponse
+ 8
People are more likely to test your code when you LINK it instead of pasting it into the description. Also, describe what issue you encounter.
19th Apr 2023, 12:18 PM
Lisa
Lisa - avatar