Input :
"The boy is running on the train"
Output expected:
["The boy", "boy is", "is running", "running on", "on the", "the train"]
What is the easiest solution to achieve this in python.
Input :
"The boy is running on the train"
Output expected:
["The boy", "boy is", "is running", "running on", "on the", "the train"]
What is the easiest solution to achieve this in python.
line="The boy is running on the train"
words=line.split()
k=[words[index]+' '+words[index+1] for index in xrange(len(words)-1)]
print k
Output
['The boy', 'boy is', 'is running', 'running on', 'on the', 'the train']