Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Three Words by -ej
def checkio(words: str) -> bool:
"""Are there 3 words of only letters in a row?"""
# a list of bool values: True for alpha-only words
ls = [word.isalpha() for word in words.split()]
# (I think this is pretty much a direct translation of the requirement.
# I am trying to be as straight-forward and non-tricky as possible.)
# Starting at the front of the list, continuing through 3 elements back from end of list...
# are there 3 Trues in a row (starting from position i)?
return any([all([ls[i], ls[i+1], ls[i+2]]) for i in range(len(ls) - 2)])
# print("Example:")
# print(checkio("Hello World hello"))
# These "asserts" are used for self-checking
assert checkio("Hello World hello") == True
#assert checkio("He is 123 man") == False
#assert checkio("1 2 3 4") == False
#assert checkio("bla bla bla bla") == True
#assert checkio("Hi") == False
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 5, 2025
Comments: