Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def validPassword(string):
- length = False
- upperCase = False
- lowerCase = False
- numBool = False
- punctBool = True
- if len(string) >= 8:
- length = True
- else:
- print ("Need at least 8 characters!")
- upCounter = 0
- for i in string:
- for u in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
- if i == u:
- upCounter +=1
- if upCounter > 0:
- upperCase = True
- else:
- print ("Need at least one upper case letter")
- lowCounter = 0
- for i in string:
- for u in "abcdefghijklmnopqrstuvwxyz":
- if i == u:
- lowCounter +=1
- if lowCounter > 0:
- lowerCase = True
- else:
- print ("Need at least one lower case letter")
- numCounter = 0
- for i in string:
- for u in "1234567890":
- if i == u:
- numCounter +=1
- if numCounter > 0:
- numBool = True
- else:
- print ("Need a number!")
- punctCounter = 0
- for i in string:
- for u in ".?,'!-_+= ":
- if i == u:
- punctCounter +=1
- if punctCounter > 0:
- punctBool = False
- print ("No punctuation or spaces please!")
- if (length and upperCase and lowerCase and numBool and punctBool):
- print ("Valid Password!")
- return True
- else:
- print ("Invalid Password!")
- return False
- validPassword("yourmomiscool")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement