Skip to content

Commit cebbf56

Browse files
authored
Merge pull request TheAlgorithms#34 from edawine/patch-1
Add another randomness into the password generator
2 parents b56cb26 + 4b43a2f commit cebbf56

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

other/password_generator.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import string
2-
from random import *
2+
import random
33

4-
letters = string.ascii_letters
5-
digits = string.digits
6-
symbols = string.punctuation
4+
letters = [letter for letter in string.ascii_letters]
5+
digits = [digit for digit in string.digits]
6+
symbols = [symbol for symbol in string.punctuation]
77
chars = letters + digits + symbols
8+
random.shuffle(chars)
89

910
min_length = 8
1011
max_length = 16
11-
password = ''.join(choice(chars) for x in range(randint(min_length, max_length)))
12-
print('Password: %s' % password)
12+
password = ''.join(random.choice(chars) for x in range(random.randint(min_length, max_length)))
13+
print('Password: ' + password)
1314
print('[ If you are thinking of using this passsword, You better save it. ]')

0 commit comments

Comments
 (0)