Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
all upper using conditional operator solution in Clear category for All Upper I by harman97
def is_all_upper(text: str) -> bool:
return text == text.upper()
# compares input text with string method upper if they are the same
# returns true
# else return false
# tries to used method upper on numbers and spaces, nothing is changed
# comparison condition returns true
if __name__ == '__main__':
print("Example:")
print(is_all_upper('ALL UPPER'))
# These "asserts" are used for self-checking and not for an auto-testing
assert is_all_upper('ALL UPPER') == True
assert is_all_upper('all lower') == False
assert is_all_upper('mixed UPPER and lower') == False
assert is_all_upper('') == True
assert is_all_upper(' ') == True
assert is_all_upper('444') == True
assert is_all_upper('55 55 5') == True
print("Coding complete? Click 'Check' to earn cool rewards!")
July 23, 2021