Skip to content

Instantly share code, notes, and snippets.

@solen003
Created July 16, 2018 09:28
Show Gist options
  • Save solen003/fe5a35f33b9c5301fa5287c9c11aeb2e to your computer and use it in GitHub Desktop.
Save solen003/fe5a35f33b9c5301fa5287c9c11aeb2e to your computer and use it in GitHub Desktop.
A website requires the users to input username and password to register. Write a program to check the validity of password input by users. Following are the criteria for checking the password: 1. At least 1 letter between [a-z] 2. At least 1 number between [0-9] 1. At least 1 letter between [A-Z] 3. At least 1 character from [$#@] 4. Minimum len…
import re
passwords = input("Type in: ")
passwords = passwords.split(",")
accepted_pass = []
for i in passwords:
if len(i) < 6 or len(i) > 12:
continue
elif not re.search("([a-z])+", i):
continue
elif not re.search("([A-Z])+", i):
continue
elif not re.search("([0-9])+", i):
continue
elif not re.search("([!@$%^&])+", i):
continue
else:
accepted_pass.append(i)
print((" ").join(accepted_pass))
@ALONEWINNER
Copy link

s=input("enter sequence of comma separated passwords :")
import re
l=s.split(",")
for i in l:
if(len(i)>=6 and len(i)<=12):
if re.search("([a-z])+", i):
if re.search("([A-Z])+", i):
if re.search("([0-9])+", i):
if re.search("([#,@,$])+", i):
print(i)

#other method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment