[Solved] How can I build a password with 2 random lowercase, uppercase, numbers and punctuation?


As i said in my comment its never a good idea to role your own security functions as security is a complex space and should be left to professionals. however you said this is just for your own training / learning so below is an example of your code but modified to work. This is by no means a well thought design, i have simply taken your code and made it work.

# Password generator
from random import shuffle, choice
import string

def create_strong_pass():
    lower = string.ascii_lowercase
    upper = string.ascii_uppercase
    number = string.digits
    punctuation = string.punctuation
    password = []
    for _ in range(2):
        password.append(choice(lower))
        password.append(choice(upper))
        password.append(choice(number))
        password.append(choice(punctuation))
    shuffle(password)
    return "".join(password)

for _ in range(10):
    print(create_strong_pass())

OUTPUT

b7B#eR?7
)V2be7!Y
3Hng7_;V
q\/mDU74
Ii03/tW:
0Md6i;K@
<:LHw0b6
2eoM&V`6
c09N)Za(
t:34T'Bo

0

solved How can I build a password with 2 random lowercase, uppercase, numbers and punctuation?