-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython_app.py
42 lines (29 loc) · 935 Bytes
/
python_app.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
38
39
40
41
42
# Random Password Generator
# By Keegan Hugh Kelly @15:18 Aug 31 2022
### Whiteboard:
# Ask user if they want to generate a password or not.
# If yes, ask for password length.
# Generate password.
# Print password.
# If inital response is no or invalid, exit program.
import string
import random
characters = list(string.ascii_letters + string.digits + "!@#$%^&*()")
def generate_password():
password_length = int(input("How long would you like your password to be? "))
random.shuffle(characters)
password = []
for x in range(password_length):
password.append(random.choice(characters))
random.shuffle(password)
password = "".join(password)
print(password)
option = input("Do you want to generate a password? (Yes/No): ")
if option == "Yes":
generate_password()
elif option == "No":
print("Goodbye")
quit()
else:
print("Invalid input, please input Yes or No")
quit()