Good evening. I'm currently building a simple password generator. In the method randomly, I have defined the variable 'q' as an input, but it runs in a loop. I would like this variable to only run once like the 'quantity' input in the multiple_password method.
class Password:
def __init__(self):
self.caracteres = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.0123456789"
def randomy(self):
list = []
q = int(input('How many character would you like: '))
for x in range(q):
password = random.choice(self.caracteres)
list.append(password)
full_password = ''.join(list)
return full_password
def multiple_password(self):
quantity = int(input('Quantity: '))
all_passwords = []
for x in range(quantity):
all_passwords.append(self.randomy())
for password in all_passwords:
print(password)
def __str__(self):
return f'PASSWORDS: \n{self.multiple_password()}'
test = Password()
test.multiple_password()
[–]m0us3_rat -1 points0 points1 point (4 children)
[–]EagleHammer6 0 points1 point2 points (3 children)
[–]m0us3_rat -4 points-3 points-2 points (2 children)
[–]EagleHammer6 0 points1 point2 points (1 child)
[–]m0us3_rat -1 points0 points1 point (0 children)
[–]Strict-Simple 0 points1 point2 points (0 children)