Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple Loop and count up solution in Clear category for Three Words by undead2k
def checkio(words: str) -> bool:
''' Couldn't work out how to turn this into a
list comprehension or anything simlar so staying with this solution
Below uses a simple count loop.
We iterate over the list of words, and each time we find a word, we
increment count. Each time we find anything else, we reset count to 0.
During our loop, if count gets to at least 3, we stop and return true.
If by the end of the loop we havent reached a count of 3, return false.
'''
count = 0
for x in words.split():
if x.isalpha() == True:
count += 1
if count >= 3:
return True
else:
count = 0
return False
July 26, 2020