Answer to Question #247016 in Python for akshy

Question #247016

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#


1
Expert's answer
2021-10-05T18:15:55-0400
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[$

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS