Advertisement
Guest User

Untitled

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