I randomly felt the urge to make a password generator, and it runs semi smoothly. However, whenever I choose to make a custom length password, it freezes and my program exits. This is supposed to be simple but...can you help?
######################
# Password Generator #
# Version 1.0 #
# Created 1/3/09 #
######################
import random
import string
def main():
r = raw_input("Do you want a custom password or a quick generated password?")
if r in "custom, Custom":
get_length()
else:
make_pass()
def get_length(l=0):
l = raw_input("How long do you want your password?")
get_digits(l)
def get_digits(le):
d = raw_input("How many digits do you want?")
make_pass(le, d)
def make_pass(length=8, digit=2):
letters = "abcdefghijklmnopqrstuvwxyz"
digits = "0123456789"
password = []
n = 0
z = 0
while z != length:
if n < digit:
i = random.randint(0, 10)
if i <= 4:
password += random.choice(letters)
else:
password += random.choice(digits)
n += 1
else:
password += random.choice(letters)
z += 1
word = string.join(password)
word = string.replace(word, " ", "")
print "Here is your new password: %s" % word
main()
Thank you so much for your help