First solution in Clear category for Three Words by sedm0784
def checkio(words: str) -> bool:
"""Check if there are three consecutive words in a string"""
# First we split the input into a list
words = words.split()
# Then we create an iterable of each set of three tokens.
# So for the input "a b c d e", triplets is set to:
# [[a, b, c], [b, c, d], [c, d, e]]
triplets = zip(words, words[1:], words[2:])
# Then we check if any of the triplets is "all words"
return any(all(word.isalpha() for word in triplet)
June 23, 2021