def _get_sentences_with_word_count(sentences, word_count):
 length = 0
 selected_sentences = []
 for sentence in sentences:
  words_in_sentence = len(sentence.text.split())
  if (abs(((word_count - length) - words_in_sentence)) > abs((word_count - length))):
   return selected_sentences
  selected_sentences.append(sentence)
  length += words_in_sentence
 return selected_sentences

def _get_sentences_with_word_count ( sentences , word_count ) : length = 0 selected_sentences = [ ] for sentence in sentences : words_in_sentence = len ( sentence . text . split ( ) ) if ( abs ( ( ( word_count - length ) - words_in_sentence ) ) > abs ( ( word_count - length ) ) ) : return selected_sentences selected_sentences . append ( sentence ) length += words_in_sentence return selected_sentences
given a list of sentences .