Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First correct capital solution in Uncategorized category for Correct Capital by karol2202
def correct_capital(line: str) -> bool:
start = line[0].isupper()
if start:
if all([word.lower() == word for word in line[1:len(line)]]):
return True
elif all([word.upper() == word for word in line[1:len(line)]]):
return True
else:
return False
else:
if all([word.lower() == word for word in line[1:len(line)]]):
return True
else:
return False
print("Example:")
print(correct_capital("Checkio"))
# These "asserts" are used for self-checking
assert correct_capital("Checkio") == True
assert correct_capital("CheCkio") == False
assert correct_capital("CHECKIO") == True
print("The mission is done! Click 'Check Solution' to earn rewards!")
Dec. 9, 2022
Comments: