forked from crazycodersonline/Python-Beginner-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustom_Password_Generator.py
46 lines (34 loc) · 1.06 KB
/
Custom_Password_Generator.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
43
44
45
import os
import random
def custom_pass(alpha,nums,schars):
str_pass =""
a= "abcdefghijklmnoprstuvwxyz"
b= "1234567890"
c= "!@#$%^&*()"
length = alpha + nums + schars
list_pass =['']*length
indices = [index for index in range(length)]
while alpha!=0:
num = random.choice(indices)
indices.remove(num)
list_pass[num] =random.choice(a)
alpha = alpha -1
while nums!=0:
num = random.choice(indices)
indices.remove(num)
list_pass[num] =random.choice(b)
nums = nums -1
while schars!=0:
num = random.choice(indices)
indices.remove(num)
list_pass[num] =random.choice(c)
schars=schars -1
str_pass = str.join("",list_pass)
#str_pass = ''.join(list_pass)
return str_pass
if __name__ =="__main__":
os.system("cls")
alpha = int(input("Enter no. of alphabets"))
nums = int(input("Enter no. of numeric characters"))
schars = int(input("Enter no. of special characters"))
print(custom_pass(alpha,nums,schars))