Skip to content

Commit 86e00af

Browse files
authored
Create password_generator.py
1 parent 977024c commit 86e00af

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import string
2+
import random
3+
4+
char = list(string.ascii_letters + string.digits + "!@#$%^&*()")
5+
6+
def generate_password():
7+
password_length = int(input("How long would your password be: "))
8+
9+
random.shuffle(char)
10+
11+
password = []
12+
13+
for x in range(password_length):
14+
password.append(random.choice(char))
15+
16+
random.shuffle(password)
17+
18+
password = "".join(password)
19+
20+
print(password)
21+
22+
option = input("Do you want to generate a pasword? (Yes/No): ")
23+
24+
if option == "Yes" or option == "yes":
25+
generate_password()
26+
print("")
27+
28+
elif option =="No" or option == "no":
29+
print("Program ended")
30+
quit()
31+
32+
else:
33+
print("Invalid input")
34+
quit()

0 commit comments

Comments
 (0)