1
+ # Automatic Password generator . .
2
+
3
+ import random
4
+
5
+ alphabets = ['a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' ,
6
+ 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' ,
7
+ 'w' , 'x' , 'y' , 'z'
8
+ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' ,
9
+ 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' ,
10
+ 'W' , 'X' , 'Y' , 'Z'
11
+ ]
12
+ numbers = ['0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ]
13
+ symbols = ['!' , '@' , '#' , '$' , '%' , '^' , '&' , '*' , '(' , ')' ,
14
+ '-' , '_' , '+' , '/' , '|' ]
15
+
16
+ print ("Welcome to password Generator ! " )
17
+
18
+ total_Alpha = int (input ("How many letters would you like in your password : \n " ))
19
+ total_Num = int (input ("How many numbers would you like in your password : \n " ))
20
+ total_Sym = int (input ("How many symbols would you like in your password : \n " ))
21
+
22
+
23
+ password_List = [] # empty list
24
+
25
+ # using random choice method . .
26
+ for letters in range (1 , total_Alpha + 1 ):
27
+ password_List += random .choice (alphabets )
28
+
29
+ for num in range (1 , total_Num + 1 ):
30
+ password_List += random .choice (numbers )
31
+
32
+ for symbls in range (1 , total_Sym + 1 ):
33
+ password_List += random .choice (symbols )
34
+
35
+ # easy method . .
36
+
37
+ password = ""
38
+ for lettter in password_List :
39
+ password += lettter
40
+
41
+ print (f"Your password : { password } " )
42
+
43
+ # hard method . . .
44
+
45
+ # random shuffle method use . .
46
+ random .shuffle (password_List )
47
+ print (password_List )
48
+
49
+ # converting password list to single word . .
50
+ password = ""
51
+ for lettter in password_List :
52
+ password += lettter
53
+
54
+ print (f"Your password : { password } " )
0 commit comments