-2

I am analyzing a text file filled with monologues and I would like to create a separate text file composed of monologues from a single character.

Here's an example:

PERSON A:

Hi

PERSON B:

Hello

My goal is to slice all monologues from Person A into a new text. I've been battling with this for hours but I have no clue. Any help?

xlvs
  • 1
  • 3
  • 1
    Please retake the [tour], read [what's on-topic here](/help/on-topic) and [ask], and provide a [mre]. "Implement this feature for me" is off-topic for this site. You have to _make an honest attempt_, and then ask a specific question about your algorithm or technique. – Pranav Hosangadi Sep 24 '20 at 16:05

1 Answers1

1

Think about which character or string separates the speeches of the persons. Use the split function and keep the delimiter. See https://docs.python.org/3/library/stdtypes.html#str.split and In Python, how do I split a string and keep the separators?. Then think about how you can identify the speeches of the persons in the result of the split function. When you can identify them separate them and write them to a file.

Michael_H
  • 1,050
  • 14
  • 28