Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import string
- all_letters = string.ascii_letters
- all_uppercase = string.ascii_uppercase
- all_lowercase = string.ascii_lowercase
- all_numbers = string.digits
- all_special = string.punctuation
- all = all_letters+all_numbers+all_special
- n = int(input("How many characters in your password? "))
- #ensuring all requirements are fullfilled first
- password = " "
- password += random.choice(all_lowercase)
- password += random.choice(all_uppercase)
- password += random.choice(all_numbers)
- password += random.choice(all_special)
- #filling the remaining characters by substracting 4 from n
- for char in range(0,n-4):
- char = random.choice(all)
- password = password + char
- print("your random password is :", password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement