forked from LorienOlive/python-fundamentals
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassword_Generator
More file actions
37 lines (32 loc) · 1.18 KB
/
Password_Generator
File metadata and controls
37 lines (32 loc) · 1.18 KB
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
import random
import string
def password_generator():
count = []
for i in range(numbers):
a = random.randint(0, 9)
count.append(str(a))
for j in range(letters):
b1 = random.choice(string.ascii_uppercase)
b2 = random.choice(string.ascii_lowercase)
b = random.choice([b1, b2])
count.append(b)
for k in range(symbols):
c = random.choice(string.punctuation)
count.append(c)
random.shuffle(count)
password = ''.join(count)
return password
while True:
length = int(input('How long should the password be? '))
numbers = int(input('How many numbers should the password have? '))
letters = int(input('How many letters should the password have? '))
symbols = int(input('How many symbols should the password have? '))
if length >= 6:
if (numbers + letters + symbols == length):
result = password_generator()
print(result)
break
else:
print('The total amount of numbers, letters, and symbols does not equal the length of the password.')
elif length < 6:
print('The length of the password must be at least six characters long.')