Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Shorter code with documentation (helpful for budding programmers) solution in Clear category for Acceptable Password I by DigitalSorcerer4225
def is_acceptable_password(password: str) -> bool:
#if len(password) <= 6:
#return False
#return True
return len(password) > 6
# Line 5 does the same thing as lines 2-4 but uses less characters!
# "Any object can be tested for truth value..."
# In this case the objects are the return value of len(password) and 6.
# The '>' is a comparison operator.
# "Comparisons yield boolean values: True or False."
# Thus, the expression len(password) > 6 evaluates to True if the object returned
# by len(password) is greater than 6. Otherwise, it evaluates to False.
# *return* then returns the value of the evaluated expression to the line that
# called the is_acceptable_password() function.
#References:
# Line 9: https://docs.python.org/3/library/stdtypes.html#id12
# Line 12-13: https://docs.python.org/3/reference/expressions.html#comparisons
# len(): https://docs.python.org/3/library/functions.html#len
if __name__ == '__main__':
print("Example:")
print(is_acceptable_password('short'))
# These "asserts" are used for self-checking and not for an auto-testing
assert is_acceptable_password('short') == False
assert is_acceptable_password('muchlonger') == True
assert is_acceptable_password('ashort') == False
print("Coding complete? Click 'Check' to earn cool rewards!")
April 28, 2022