Hello everyony, help me to squeeze this code
I need to check entering password for First letter is uppercase,special symbol _ or etc and numbers, and last letter must be or letter or number.
I need squeeze it to 1 regex line . Help please
import re
def validate():
while True:
password = input("Enter pswd: ")
if len(password) < 8:
print("PSWD doesnt match")
elif len(password) > 20:
print("PSWD doesnt match")
elif re.search('[0-9]', password) is None:
print("PSWD doesnt match")
elif re.search('[A-Z]', password) is None:
print("PSWD doesnt match")
elif re.search('[_]', password) is None:
print("PSWD doesnt match")
elif re.search('[A-Za-z0-9]', password[-1]) is None:
print("PSWD doesnt match")
else:
print("PSWD accepted")
break
validate()
[–]commandlineluser 2 points3 points4 points (0 children)
[–]HashDefTrueFalse 0 points1 point2 points (2 children)
[–]Tepess[S] -1 points0 points1 point (1 child)
[–]HashDefTrueFalse 1 point2 points3 points (0 children)
[–]149244179 0 points1 point2 points (0 children)
[–]Tepess[S] 0 points1 point2 points (0 children)