Question 1: Create a program to generate a password length 12 6 random == "A-Z a-z" 4 --> digits 2 -- > special characters Expected Output: $ji12kt56yU#
import random
import string
letters = string.ascii_letters
digits = string.digits
spec = string.punctuation
list1 = []
for i in range(12):
if i <= 5:
s = random.choice(letters)
list1.append(s)
elif 5 < i <= 9:
s = random.choice(digits)
list1.append(s)
else:
s = random.choice(spec)
list1.append(s)
password = ''.join(list1)
print(password)
nYHYLL7661[$
Comments
Leave a comment