Return to Snippet

Revision: 55530
at May 31, 2013 20:24 by p1p1092


Updated Code
import random

def main():
    while True:
        stop = input("Generate password? y/n: ")
        if stop and stop[0].lower() == "n":
            break

        length = int

        size = input("What length do you want the password to be(4-20): ")
        length = int(size)
                    
        chars = string.ascii_letters + string.digits
        return ''.join(random.choice(chars) for x in range(length))

Revision: 55529
at February 10, 2012 06:36 by p1p1092


Initial Code
import string
import random

def main():
    while True:
        stop = input("Generate password? y/n: ")
        if stop and stop[0].lower() == "n":
            break

        length = int

        size = input("What length do you want the password to be(4-20): ")
        if size == "4":
            length = 4
        if size == "5":
            length = 5
        if size == "6":
            length = 6
        if size == "7":
            length = 7
        if size == "8":
            length = 8
        if size == "9":
            length = 9
        if size == "10":
            length = 10
        if size == "11":
            length = 11
        if size == "12":
            length = 12
        if size == "13":
            length = 13
        if size == "14":
            length = 14
        if size == "15":
            length = 15
        if size == "16":
            length = 16
        if size == "17":
            length = 17
        if size == "18":
            length = 18
        if size == "19":
            length = 19
        if size == "20":
            length = 20
        else:
            length = 6
            
        chars = string.ascii_letters + string.digits
        return ''.join(random.choice(chars) for x in range(length))

Initial URL

                                

Initial Description
A simple python password generator...

Initial Title
Python Password Generator

Initial Tags
python

Initial Language
Python