I have written a Pythonpython program for random password generation, and as a newbie I would like my code to be reviewed by professionals to seeand if they have any suggestions to improve it.
import string
import random
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n"))
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))
#...................................................
password = []
finalpassword = []
counter_l = 0
for l in letters_list :
password.append(random.choice(letters_list))
counter_l += 1
if counter_l == many_letter :
break
counter_d = 0
for d in digits_list :
password.append(random.choice(digits_list))
counter_d += 1
if counter_d == many_digit :
break
counter_s = 0
for s in special_list :
password.append(random.choice(special_list))
counter_s += 1
if counter_s == many_special :
break
p_counter = 0
for p in password :
finalpassword.append(random.choice(password))
p_counter += 1
if p_counter == len(password) :
break
print("".join(finalpassword))