text = ['For', 'our', 'purposes', 'a', 'sentence', 'is', 'the', 'sequence', 'of', 'words', 'between', 'one', 'period', 'exclamation', 'point', 'or', 'question', 'make', 'and', 'the', 'next', 'one.', 'The', 'program', 'as', 'written', 'first', 'breaks', 'the', 'text', 'into', 'a', 'list', 'of', 'words', 'without', 'any', 'punctuation', 'or', 'special', 'characters.', 'To', 'compute', 'the', 'length', 'of', 'sentences', 'with', 'our', 'definition', 'you', 'should', 'leave', 'in', 'periods', 'exclamation', 'points', 'and', 'question', 'marks', 'at', 'first', 'in', 'order', 'to', 'do', 'the', 'counting', 'and', 'then', 'remove', 'them', 'later.'] print (text) beg = 0 end = 0 lengths = [] while(end < len(text)): if text[end][-1] == '.': print("begins at ", beg, "ends at ", end) lengths.append(end - beg + 1) beg = end +1 text[end] = text[end][0:-1] end = end + 1 print(lengths) print(text)