File tree 1 file changed +16
-10
lines changed
1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change 1
- import random
2
- import string
1
+ from random import choice
2
+ from string import printable
3
3
4
4
5
- def randompassword (number ):
6
- chars = random .sample (string .ascii_lowercase + string .digits , number )
7
- passw = '' .join (map (str , chars ))
8
- return passw
5
+ def random_password (length ):
6
+ """
7
+ Provides a random password of the given length.
9
8
9
+ :param int length: The length of the password to generate.
10
+ """
10
11
11
- amount = int (input ("How many passwords:\n " ))
12
- number = int (input ("Lenght of password?\n " ))
13
- for i in range (amount ):
14
- print (f" Password: { i } - { randompassword (number )} " )
12
+ return "" .join ([choice (printable ) for x in range (int (length ))])
13
+
14
+
15
+ if __name__ == "__main__" :
16
+ amount = int (input ("How many passwords: " ))
17
+ number = int (input ("Length of password? " ))
18
+
19
+ for i in range (1 , amount + 1 ):
20
+ print (f" Password: { i } - { repr (random_password (number ))} " )
You can’t perform that action at this time.
0 commit comments