Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Have the program create random strong passwords mixing upper and lower case,
- symbols and numbers.
- The user can choose how long they want the password to be.
- A strong password must contain:
- • a capital letter
- • a number
- • a symbol.
- """
- import random
- caps =["A","B","C"]# see second part for a way to auto populate
- numb = ["0","1","2"]
- symb = ["!",'"',"£"]
- lows = ["a","b","c"]
- alls = []
- # populates the alls list
- alls.extend(caps)
- alls.extend(numb)
- alls.extend(symb)
- alls.extend(lows)
- #print(alls)
- chars_needed = int()
- password=[] # to hold the password
- while chars_needed <3:
- chars_needed = int(input("Enter number of characters you'd like (min 3) >> "))
- password.append(random.choice(caps))
- password.append(random.choice(numb))
- password.append(random.choice(symb))
- #print(password)
- for i in range(chars_needed-3):
- password.append(random.choice(alls))
- random.shuffle(password)
- passwordstring = ""
- for i in range(len(password)):
- passwordstring += password[i]
- #passwordstring = passwordstring + password[i]
- print(password)
- print(passwordstring)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement