18 lines
625 B
Python
18 lines
625 B
Python
def validate(pw):
|
|
"""Check four properties of a non-empty password and return a dict.
|
|
|
|
Keys:
|
|
"length" — number of characters (int)
|
|
"long_enough" — True if length >= 8 (bool)
|
|
"starts_capital" — True if first char is uppercase (bool)
|
|
"ends_digit" — True if last char is a digit (bool)
|
|
|
|
Helpers:
|
|
pw[0].isupper() — True if first char is uppercase
|
|
pw[-1].isdigit() — True if last char is a digit
|
|
|
|
validate("Andromeda1") -> {"length": 10, "long_enough": True,
|
|
"starts_capital": True, "ends_digit": True}
|
|
"""
|
|
pass
|