The function is to find out how strong password is. It's considered strong if:
- length is greater than or equal to 10 characters
- it contains at least one digit
- at least one uppercase letter
- one lowercase letter
- the password may only contain ASCII latin letters or digits
Is there a way to reduce the amount of code in the function? Please help me make the code of function shorter than 200 characters (try to solve without assigning values to variables)
import re
def golf(password):
if len(password) >= 10 \
and re.search("^[a-zA-Z0-9]+", password) \
and re.search("[a-z]+", password) \
and re.search("[A-Z]+", password) \
and re.search("[0-9]+", password):
print(password, True)
return True
else:
print(password, False)
return False
if __name__ == '__main__':
golf('A1213pokl') == False
golf('bAse730onE') == True
golf('asasasasasasasaas') == False
golf('QWERTYqwerty') == False
golf('123456123456') == False
golf('QwErTy911poqqqq') == True
golf('..........') == False