[Python] Password Generator Program [closed]

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    import string
    import random

    def spw_gen(size = 8, chars = string.ascii_letters + string.digits + string.punctuation):
    return ''.join(random.choice(chars) for x in range(size))
    def mpw_gen(size = 8, chars = string.ascii_letters + string.digits):
    return ''.join(random.choice(chars) for x in range(size))
    def wpw_gen(size = 8, chars = string.ascii_letters):
    return ''.join(random.choice(chars) for x in range(size))

    strength = str(input("How strong do you want your password to be(s/m/w): "))
    if strength == 's':
    print(spw_gen(int(input('How many characters in your password: '))))
    elif strength == 'm':
    print(mpw_gen(int(input('How many characters in your password: '))))
    elif strength == 'w':
    print(wpw_gen(int(input('How many characters in your password: '))))
    else:
    print("Correct command not entered")


    My question is that even after we are defining size=8, how are we getting password with more than 8 characters?

    Continue reading...

Compartilhe esta Página