import re
line = "the heart was made to be broken"
line_split2 = re.split(r [
, ]+ ,line)
def chunks(line_split2, n):
for i in xrange(0, len(line_split2), n):
yield line_split2[i:i+n]
separate_word = list(chunks(line_split2, 3))
import pprint
pprint.pprint(separate_word)
count = 0
for lines in separate_word:
count = count + 1
print count
我正试图把名单合并起来,作为判刑,并在前面显示线数。
1 the heart was
2 made to be
3 broken
Any suggest?