Skip to content

Commit 5f12a5d

Browse files
authored
Create main.py
1 parent 47becb0 commit 5f12a5d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

day05/main.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import random
2+
3+
4+
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']
5+
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
6+
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
7+
8+
print("Welcome to the PyPassword Generator!")
9+
nr_letters= (input("How many letters would you like in your password?\n"))
10+
nr_symbols = (input(f"How many symbols would you like?\n"))
11+
nr_numbers = (input(f"How many numbers would you like?\n"))
12+
13+
if not nr_letters.isdigit() or not nr_symbols.isdigit() or not nr_numbers.isdigit():
14+
print("Invalid value, enter a number instead.")
15+
else:
16+
password = []
17+
18+
random_letter = random.randint(0, 51)
19+
for i in range(0, int(nr_letters)):
20+
random_letter = random.randint(0, 51)
21+
password.append(letters[random_letter])
22+
23+
random_number = random.randint(0,9)
24+
for i in range(0, int(nr_numbers)):
25+
random_number = random.randint(0,9)
26+
password.append(numbers[random_number])
27+
28+
random_symbol = random.randint(0,8)
29+
for i in range(0, int(nr_symbols)):
30+
random_symbol = random.randint(0,8)
31+
password.append(symbols[random_symbol])
32+
33+
random.shuffle(password)
34+
print(f"Here is your password: {''.join(password)}")
35+
36+
if len(password) <= 6:
37+
print("Your password is weak, try to include at least 8 characters for a stronger password.")
38+
elif len(password) == 7:
39+
print("Your password is medium, try to include at least 8 characters for a stronger password.")
40+
else:
41+
print("Your password is strong.")

0 commit comments

Comments
 (0)