-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpython-passcode_generator-Sanyog_Mishra.py
executable file
·37 lines (29 loc) · 1.29 KB
/
python-passcode_generator-Sanyog_Mishra.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Password Generator Project
import random
letters = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
]
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
print("\n------SecureZ Password Generator!------")
nl = int(input("\nHow many letters would you like in your password?: "))
ns = int(input("How many symbols would you like?: "))
nn = int(input("How many numbers would you like?: "))
list_p = list(range(nl + ns + nn)) # creating list of size of total length of password
for n in range(nl):
a = random.randint(0, len(letters) - 1)
list_p[n] = letters[a]
for n in range(ns):
a = random.randint(0, len(symbols) - 1)
list_p[nl + n] = symbols[a]
for n in range(nn):
a = random.randint(0, len(numbers) - 1)
list_p[nl + ns + n] = numbers[a]
random.shuffle(list_p) # shuffling to add degree of unpredictability
passcode=''
for n in range(len(list_p)):
passcode = passcode + list_p[n]
print(f"Your password: {passcode}") # displaying the generated password