In: Computer Science
Password check, lab2pr1.py Many websites these days require that
a password
is between 8 and 20 characters, doesn’t have spaces, and satisfies
the following
conditions: contain at least one uppercase letter, contain at least
lowercase letter,
contain at least one number, and contain at least one special
symbol character
(”!?,.;:$# &”). Write a program that keeps asking the user to
enter the password
until they enter one that satisfies the requirements.
Please enter a password:
@Tulane2020
Please enter a password:
#Tulane2020
Password accepted
use python
import re
#checks for uppercase
def upperCheck(password):
return any(x.isupper() for x in password)
#checks for lowercase
def lowerCheck(password):
return any(x.islower() for x in password)
#checks for digit
def digitCheck(password):
return any(x.isdigit() for x in password)
#checks for special char
def specialCheck(password):
regex = re.compile('[!?,.;:$#&]')
return regex.search(password) != None
while(True):
password=input("Enter password: ")
if upperCheck(password) and lowerCheck(password) and
digitCheck(password) and specialCheck(password) and
len(password)>= 8 and len(password)<=20:
print(password," is valid password")
break
else:
print(password,"is invalid password.Try again..")
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me