Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Passwords generator
- # Initialise characters for password
- from random import choice
- alpha = ("abcdefghijklmnopqrstuvwxyz")
- nos = ("0123456789")
- symbols = ("!?#$£%&")
- chset = ("012")
- password = ['.','.','.','.','.','.','.','.']
- #
- def gen_password():
- noofchars = int(input("How many characters do you require - max 8 "))
- # noofchars = int(noofchars)
- if noofchars > 8:
- noofchars = 8
- print ("password length " + str(noofchars))
- # generate password
- for i in range (0, noofchars):
- # find a random character from alpha, nos, symbols
- rand = int(choice(chset))
- if rand == 0:
- character = choice(alpha)
- if rand == 1:
- character = choice(nos)
- if rand == 2:
- character = choice(symbols)
- password[i] = character
- # print password
- print ("password of " + str(noofchars) + " chars = ")
- for i in range (0, noofchars):
- print (password[i])
- print ("bye")
- gen_password()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement