I have the following python code:
import regex
original = " the quick ' brown 1 fox! jumps-over the 'lazy' doG? ! "
s = [i for i in original.split(" ")]
I want to write a function called get_sentence which takes an element within s and returns the sentence as a string to which the element belongs. For example:
"brown" -> "the quick ' brown 1 fox!"
if the first “the” is passed to the function, then:
"the" -> the quick ' brown 1 fox!"
if the second the:
"the" -> "jumps-over the 'lazy' doG?"
What would you pass as an argument to such a function? In C++ I might pass in an std::vector::const_iterator. In C I would pass in an int (array index) or maybe even a pointer.
1 Answer