Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. from sys import *
  2. from string import *
  3.  
  4. password = input(
  5. """
  6. Please enter your password.
  7. Passwords must be more than 10 characters long,
  8. But less than 20 characters long.
  9. include both upper and lower case letters
  10. and atleast 1 special character.
  11. password can contain no spaces.
  12. type password here:""")
  13.  
  14. lwr_let = list(ascii_lowercase)
  15. upr_let = list(ascii_uppercase)
  16. nums = list(digits)
  17. spcs = list(punctuation)
  18.  
  19. lwr_let_count = 0
  20. upr_let_count = 0
  21. nums_count = 0
  22. spcs_count = 0
  23.  
  24. if len(password) < 10 or len(password) > 20:
  25. exit("Password length not met, try again")
  26.  
  27. for i in password:
  28. if i in lwr_let:
  29. lwr_let_count += 1
  30. elif i in upr_let:
  31. upr_let_count += 1
  32. elif i in nums:
  33. nums_count += 1
  34. elif i in spcs:
  35. spcs_count += 1
  36. elif i == " ":
  37. exit("spaces are not allowed. Please try again.")
  38. else:
  39. exit("One of your characters is not allowed. Please try again.")
  40.  
  41. if lwr_let_count == 0:
  42. exit("No lowercase letters detected, try again")
  43. if upr_let_count == 0:
  44. exit("No uppercase letters detected, try again")
  45. if nums_count == 0:
  46. exit("No numbers detected, try again")
  47. if spcs_count == 0:
  48. exit("No special characters detected, try again")
  49.  
  50. print("password setup complete. Password is %s" % (password))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement