DEV Community

T-Roy
T-Roy

Posted on

Password Creator Simple

import random
import string

print("welcome to password generator")

len = int(input("enter the number of characters in your password: "))
let = int(input("enter the number of letters in your password: "))
num = int(input("enter the number of numbers in your password: "))
sym = int(input("enter the number of symbols in your password: "))

if len != let + num + sym:
print("the number of characters should be equal to the sum of letters, numbers and symbols")

elif len == let + num + sym:
password = (
random.choices(string.ascii_letters, k=let) +
random.choices(string.digits, k=num) +
random.choices(string.punctuation, k=sym)
)
random.shuffle(password)

print("your password is: ", "".join(password))

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.