DEV Community

Cover image for Day 9: Password Generator

Day 9: Password Generator

mattryanmtl profile image Matt Ryan ・1 min read

A password generator that asks the user how many passwords to generate and at what length.


import random

Password Generator

chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@£$%^&*().,?0123456789'

number = input('number of passwords?')
number = int(number)

length = input('password length?')
length = int(length)

print('\nhere are your passwords:')

for pwd in range(number):
  password = ''
  for c in range(length):
    password += random.choice(chars)
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

Forem Open with the Forem app