how to make password stengthener in python code example

Example 1: password generator python

#This is giving you a password with 8 strings and 4 numbers:
import random
i=0 
list=[]
while i < 12:
    while i < 8:
        list.append(random.choice(string.ascii_letters))
        i+=1
    while i < 12:
        list.append(random.randint(0, 9))
        i+=1
    
list=' '.join([str(elem) for elem in list])
print("Your new password: ", list.replace(" ", ""))

Example 2: python safe password string generator

# 32 characters 16 letters 14(remaining) integers
import random
import string
i=0 
list_p=[]
while i < 32:
    while i < 18:
        list_p.append(random.choice(string.ascii_letters))
        i+=1
    while i < 32:
        list_p.append(random.randint(0, 9))
        i+=1
stringified_list = [str(i) for i in list_p]
random.shuffle(stringified_list)
new_password = "".join(stringified_list)