I want to make password generator but I have a little problem. I want a password which included uppercase+lowercase+number+specialchar. Sometimes it works, it incluedes everything but sometimes it doesn't.
Here's my code
import random
alphabet = "abcdefghijklmnopqrstuvwxyz"
lchar4pass = alphabet
uchar4pass = alphabet.upper()
numb4pass = "0123456789"
schar4pass = "()_-+[]{;}/.,!@$%#&*"
passlen = 0
while True:
try:
passlen = int(input("Enter the lenght of passw0rd: "))
except:
print("\nYou can't use a letter or a word for length.")
if passlen > 11 and passlen < 83:
break
else:
print("\nEnter a number between 11 and 83.\n")
passw0rd = lchar4pass + uchar4pass + numb4pass + schar4pass
passw0rd = "".join(random.sample(passw0rd,passlen))
print(passw0rd)
Thanks!
Aucun commentaire:
Enregistrer un commentaire