|
| 1 | +#Password Generator Project |
| 2 | +import random |
| 3 | +letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', |
| 4 | + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', |
| 5 | + 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', |
| 6 | + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', |
| 7 | + 'W', 'X', 'Y', 'Z'] |
| 8 | +numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] |
| 9 | +symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+'] |
| 10 | + |
| 11 | +print("Welcome to the PyPassword Generator!") |
| 12 | + |
| 13 | + |
| 14 | +no_letters=int(input("How many letters would you like to use in password?\n")) |
| 15 | +no_symbols=int(input("How many symbols would you like? \n")) |
| 16 | +no_numbers=int(input("How many numbers would you like? \n")) |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +def easy_version(): |
| 22 | + password = "" |
| 23 | + for i in range(no_letters): |
| 24 | + ran=random.randint(0,len(letters)) |
| 25 | + password+=letters[ran] |
| 26 | + for i in range(no_numbers): |
| 27 | + ran=random.randint(0,len(numbers)) |
| 28 | + password+=str(numbers[ran]) |
| 29 | + for i in range(no_symbols): |
| 30 | + ran=random.randint(0,len(symbols)) |
| 31 | + password+=str(symbols[ran]) |
| 32 | + print(password) |
| 33 | + |
| 34 | +def hard_version(): |
| 35 | + password_list=[] |
| 36 | + password="" |
| 37 | + for i in range(no_letters): |
| 38 | + ran=random.randint(0,len(letters)-1) |
| 39 | + password_list+=letters[ran] |
| 40 | + for i in range(no_numbers): |
| 41 | + ran=random.randint(0,len(numbers)-1) |
| 42 | + password_list+=str(numbers[ran]) |
| 43 | + for i in range(no_symbols): |
| 44 | + ran=random.randint(0,len(symbols)-1) |
| 45 | + password_list+=str(symbols[ran]) |
| 46 | + |
| 47 | + random.shuffle(password_list) |
| 48 | + for i in password_list: |
| 49 | + password+=i |
| 50 | + |
| 51 | + print(password) |
| 52 | + |
| 53 | + |
| 54 | +hard_version() |
| 55 | + |
| 56 | + |
0 commit comments