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.
Input: A string with words.
Output: The answer as a boolean.
Precondition: The input contains words and/or numbers. There are no mixed words (letters and digits combined).
0 < len(words) < 100
for j in x:
if j in string.digits:
if " " in words:
wordlist = words.split(" ")
if len(wordlist) < 3:
for i in range(len(wordlist)-2):
if test(wordlist[i]) and test(wordlist[i+1]) and test(wordlist[i+2]):
i += 1
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.