Advertisement
timber101

07_Password_part1

Jan 30th, 2022
397
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None
  1. """
  2. Have the program create random strong passwords mixing upper and lower case,
  3. symbols and numbers.
  4. The user can choose how long they want the password to be.
  5. A strong password must contain:
  6. • a capital letter
  7. • a number
  8. • a symbol.
  9.  
  10. """
  11. import random
  12.  
  13. caps =["A","B","C"]# see second part for a way to auto populate
  14. numb = ["0","1","2"]
  15. symb = ["!",'"',"£"]
  16. lows = ["a","b","c"]
  17. alls = []
  18.  
  19. # populates the alls list
  20. alls.extend(caps)
  21. alls.extend(numb)
  22. alls.extend(symb)
  23. alls.extend(lows)
  24.  
  25. #print(alls)
  26.  
  27. chars_needed = int()
  28. password=[] # to hold the password
  29.  
  30. while chars_needed <3:
  31. chars_needed = int(input("Enter number of characters you'd like (min 3) >> "))
  32.  
  33. password.append(random.choice(caps))
  34. password.append(random.choice(numb))
  35. password.append(random.choice(symb))
  36. #print(password)
  37.  
  38. for i in range(chars_needed-3):
  39. password.append(random.choice(alls))
  40. random.shuffle(password)
  41.  
  42. passwordstring = ""
  43. for i in range(len(password)):
  44. passwordstring += password[i]
  45. #passwordstring = passwordstring + password[i]
  46. print(password)
  47. print(passwordstring)
  48.  
Advertisement
RAW Paste Data Copied
Advertisement