Advertisement
R8za

5.5 - Password Generator

Jun 25th, 2022
822
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None
  1. #Password Generator Project
  2. import random
  3. letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
  4. numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
  5. symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
  6.  
  7. print("Welcome to the PyPassword Generator!")
  8. nr_letters= int(input("How many letters would you like in your password?\n"))
  9. nr_symbols = int(input(f"How many symbols would you like?\n"))
  10. nr_numbers = int(input(f"How many numbers would you like?\n"))
  11.  
  12. #Eazy Level - Order not randomised:
  13. #e.g. 4 letter, 2 symbol, 2 number = JduE&!91
  14.  
  15. import random
  16. # password = ""
  17. # for char in range(1, nr_letters +1):
  18. #     random_letters = random.choice(letters)
  19. #     password += random_letters
  20. #
  21. # for numb in range(1, nr_letters +1):
  22. #     random_number = random.choice(numbers)
  23. #     password += random_number
  24. #
  25. # for symb in range(1, nr_symbols +1):
  26. #     random_symbol = random.choice(symbols)
  27. #     password += random_symbol
  28. #
  29. # print(password)
  30.  
  31.  
  32.  
  33. #Hard Level - Order of characters randomised:
  34. #e.g. 4 letter, 2 symbol, 2 number = g^2jk8&P
  35.  
  36. import random
  37. password_list = []
  38.  
  39. for char in range(1, nr_letters +1):
  40.     random_letters = random.choice(letters)
  41.     password_list += random_letters
  42.  
  43. for symb in range(1, nr_symbols +1):
  44.     random_symbol = random.choice(symbols)
  45.     password_list += random_symbol
  46.  
  47. for numb in range(1, nr_numbers +1):
  48.     random_number = random.choice(numbers)
  49.     password_list += random_number
  50.  
  51. print(password_list)
  52. random.shuffle(password_list)
  53. print(password_list)
  54.  
  55.  
  56. password = ""
  57. for char in password_list:
  58.     password += char
  59.  
  60. print(f"Your password is {password}")
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
Advertisement
RAW Paste Data Copied
Advertisement