Second solution in Speedy category for Three Words by
def checkio(words, n = 3): # n = number of consecutive words to reach
# this one doesn't look at all the strings
# if one string is not a word, it is necessary to
# look at the two next strings only if the third next is a word
# for example, in a list of non words, just look at every third string
# to return False
t = words.split(' ')
c = n-1 #the first to test is the third
while c < len(t) :
if t[c].isalpha() : # if word
for k in range(1,n) : # test the two before it
if not t[c-k].isalpha() : #if one is not a word
c += n-k # we can pass 3 strings
else : # t[c], t[c-1], t[c-2] are words
else : # t[c] is not a word
c += n # # we can pass 3 strings
else : # no 3 words found
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("Hello World hello") == True, "Hello"
assert checkio("He is 123 man") == False, "123 man"
assert checkio("1 2 3 4") == False, "Digits"
assert checkio("bla bla bla bla") == True, "Bla Bla"
assert checkio("Hi") == False, "Hi"
Feb. 28, 2014