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))