Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. def validPassword(string):
  2. length = False
  3. upperCase = False
  4. lowerCase = False
  5. numBool = False
  6. punctBool = True
  7. if len(string) >= 8:
  8. length = True
  9. else:
  10. print ("Need at least 8 characters!")
  11. upCounter = 0
  12. for i in string:
  13. for u in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
  14. if i == u:
  15. upCounter +=1
  16. if upCounter > 0:
  17. upperCase = True
  18. else:
  19. print ("Need at least one upper case letter")
  20. lowCounter = 0
  21. for i in string:
  22. for u in "abcdefghijklmnopqrstuvwxyz":
  23. if i == u:
  24. lowCounter +=1
  25. if lowCounter > 0:
  26. lowerCase = True
  27. else:
  28. print ("Need at least one lower case letter")
  29. numCounter = 0
  30. for i in string:
  31. for u in "1234567890":
  32. if i == u:
  33. numCounter +=1
  34. if numCounter > 0:
  35. numBool = True
  36. else:
  37. print ("Need a number!")
  38. punctCounter = 0
  39. for i in string:
  40. for u in ".?,'!-_+= ":
  41. if i == u:
  42. punctCounter +=1
  43. if punctCounter > 0:
  44. punctBool = False
  45. print ("No punctuation or spaces please!")
  46. if (length and upperCase and lowerCase and numBool and punctBool):
  47. print ("Valid Password!")
  48. return True
  49. else:
  50. print ("Invalid Password!")
  51. return False
  52.  
  53. validPassword("yourmomiscool")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement