-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
59 lines (52 loc) · 1.5 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def main():
print "Welcome to the password generator!"
length = getLength()
contains = raw_input("Choose from the following what should the password contains \n1)Uppercase letters\n2)Lowercase letters\n3)Numbers\n4)Symbols\nInput can be 1234>> ")
contains = list(contains)
toInt(contains)
contains.sort()
print contains
password = raw_input("Enter a word: ")
password = removeSpaces(password)
print password
print createPassword(length,contains,password)
def Generator(char):
char = char.replace("A","4")
char = char.replace("a","@")
char = char.replace("e","3")
char = char.replace("","")
char = char.replace("","")
char = char.replace("","")
char = char.replace("","")
return char
def createPassword(length,contains,password):
l = []
cnt = 0
while(len(l) != length):
l.append(Generator(password[cnt]))
cnt+=1
return listToStr(l)
def listToStr(lst):
Str = ''
for i in range(len(lst)):
Str += lst[i]
return Str
def toInt(lst):
'''(lst)->(none)
toInt convert a list of strings to integers
'''
for i in range(len(lst)):
lst[i] = int(lst[i])
def removeSpaces(Str):
return Str.replace(' ','')
def getLength():
length = 0
try:
length = input("Please Enter the length of the password you want to enter: ")
except NameError:
print "*This input accepts only numbers"
getLength()
finally:
return length
if __name__=='__main__':
main()