for line in lines:
    if line.startswith(sent):
        yield current
current = []
current.append(line)
yield current
data = """line1
text1
text2
text3
line2
something1
something2""".splitlines()
print(['|'.join(line) for line in join_lines(data) if line])
How can I combine multiple lines of text into one line in Python with a delimiter to separate them?