Let's teach the Robots to distinguish words and numbers.
You are given a string with words and numbers separated by whitespaces (one space). The words contains only letters. You should check if the string contains three words in succession. For example, the string "start 5 one two three 7 end" contains three words in succession.
A string with words.
The answer as a boolean.
The input contains words and/or numbers. There are no mixed words (letters and digits combined).
0 < len(words) < 100
def checkio(words): import string def test(x): for j in x: if j in string.digits: return False break else: return True if " " in words: wordlist = words.split(" ") if len(wordlist) < 3: return False else: for i in range(len(wordlist)-2): if test(wordlist[i]) and test(wordlist[i+1]) and test(wordlist[i+2]): return True break i += 1 else: return False else: return False
For boolean output, that means we need to use if statement. To check every word in a list or every character in a word, we need to use for loop.
Copyright © Vantopics