-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrandom_password_generator.py
More file actions
48 lines (29 loc) · 1.12 KB
/
random_password_generator.py
File metadata and controls
48 lines (29 loc) · 1.12 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
38
39
40
41
42
43
44
45
46
47
48
# A simple program that helps users to get a password idea.
import random
import string
def Storage():
characters = list(string.ascii_letters + string.digits + '!@#$%^&*()')
options = ['y', 'n']
return characters, options
def get_password(characters, options):
while True:
user_choice = input('Do you want to generate a new password (y/n): ').lower()
if user_choice not in options:
print('Enter a valid choice (y/n)')
else:
if user_choice == 'y':
password_length = int(input('Enter password length: '))
random.shuffle(characters)
password = []
for x in range(password_length):
password.append(random.choice(characters))
random.shuffle(password)
password = ''.join(password)
print(password)
else:
print('Thanks for using this program...😁')
break
def Main():
characters, options = Storage()
get_password(characters, options)
Main()