Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import random
- import string
- def ask():
- options = ["weak", "strong"]
- user = input("Do you want a weak or strong password? ")
- if user.lower() in options:
- return user
- else:
- print("you have not entered 'weak' or 'strong'")
- ask()
- def weak():
- dictionary = ["dog", "cat"]
- max = int(len(dictionary)) - 1
- select = random.randint(0, max)
- select2 = random.randint(0, max)
- wpassword = dictionary[select] + dictionary[select2]
- print(wpassword)
- def strong():
- x = random.randint(6, 15)
- y = 0
- pas = []
- while x > 0:
- ran = random.choice(string.ascii_lowercase + string.digits + string.ascii_uppercase + string.punctuation)
- pas.append(ran)
- x -= 1
- spassword = ''.join(pas)
- print(spassword)
- def gen():
- if ask() == "weak":
- weak()
- else:
- strong()
- gen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement