PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def checkio(text: str) -> bool:
words = text.split() # Split the text into a list of words
consecutive_words = 0 # Initialize a counter for consecutive words
for word in words:
if word.isalpha(): # Check if the word consists only of alphabetic characters
consecutive_words += 1 # Increment the counter if it's a word
if consecutive_words == 3: # Check if there are three consecutive words
return True
else:
consecutive_words = 0 # Reset the counter if it's not a word
return False # Return False if the loop completes without finding three consecutive words
# Example usage
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") == True
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run