daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Date ??/??/2017
  2. #Practice Python #16 - Password Generator
  3. #Ask the user how strong they want their password to be
  4. #For a weak password, pick a word or two from a list
  5.  
  6.  
  7. import random
  8. import time
  9.  
  10. def main():
  11.     choice = menu()
  12.     password = generatePassword(choice)
  13.     print("Your password is",password)
  14.  
  15. def menu():
  16.     choice = input("Do you want a weak or strong password:\n---> ")
  17.     return choice
  18.  
  19. def generatePassword(choice):
  20.     if choice.lower() == "weak" or choice.lower() == "w":
  21.         print("You have chosen a weak password")
  22.         password = random.choice(['Scott', 'April', 'Bryan', 'Grace']) + random.choice(['Scott','April','Bryan','Grace'])
  23.     elif choice.lower() == "strong" or choice.lower() == "s":
  24.         print("You have chosen a strong password")
  25.         keywords = "!@#$%^&*()qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASFGHJKLZXCVBNM"
  26.         password = ''.join(map(str,random.sample(keywords, 10)))
  27.     else:
  28.         print("Choose a valid option")
  29.     return password
  30.  
  31. if __name__ == "__main__":
  32.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top