Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##Write a password generator in Python. Ask the user how strong they want their
- ##passport to be. Be creative with how you generate passwords - strong
- ##passwords have a mix of lowercase letters, uppercase letters, numbers,
- ##and symbols. The passwords should be random, generating a new password
- ##every time the user asks for a new password. Include your run-time code
- ##in a main method.
- import random
- #There are 3 lists, each adding a level of strength to the password
- letter_mix = list("qwertyuiopasdfghjklzxcvbnm")
- letter2_mix = list("QWERTYUIOPASDFGHJKLZXCVBNM")
- symbol_mix = list("1234567890`+,.-^*<>;:_'?")
- merged_list = letter_mix + letter2_mix
- merged_list2 = merged_list + symbol_mix
- human = input("How long do you want your passport to be? (4-9)")
- def password_generator(x):
- human2 = raw_input("How strong do you want your passport to be? (strong/medium/weak)")
- if human2 == "weak":
- list_random = random.sample(letter_mix, x)
- list2 = ''.join(list_random)
- print list2
- elif human2 == "medium":
- list_random = random.sample(merged_list, x)
- list2 = ''.join(list_random)
- print list2
- elif human2 == "strong":
- list_random = random.sample(merged_list2, x)
- list2 = ''.join(list_random)
- print list2
- else:
- print "Sorry, that was not one of the options. Please tape either 'weak', 'medium' or 'strong'"
- continuar = raw_input("Do you want to generate another passport? (y/n)")
- if continuar == "y":
- b = True
- elif continuar == "n":
- b = False
- print "See you soon"
- else:
- print "Sorry, that was not one of the options"
- password_generator(human)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement