jweinst1
6/20/2015 - 8:07 AM

Sentence Slicer.py

Sentence Slicer.py

#returns the slices of varying lengths after a word in a string sentence,


def sentence_word_slicer(string, word):
	wordlist, sent_frags = string.split(), []
	start, end = wordlist.index(word), len(wordlist) - 1
	while start != end:
		sent_frags.append(wordlist[start:end])
		end -= 1
	return sent_frags