Question: I have a text that I'm splitting into a list of sentences, and I want to find the subject of each sentence. For example, if the text is 'Dogs are great. They are so awesome', they have to be splitted into the two sentences 'Dogs are great.' and 'They are so awesome'. Then I use a for loop to find what the subject of each sentence is, whether it is 'cats' or 'dogs'.

```
sentence_list=['Dogs are great', 'They are so awesome']
for sentence in sentence_list:
    if 'Dog' in sentence:
        subject= 'Dog'
    elif 'Cat' in sentence:
        subject='Cat'

```

Because 'They' is used as a replacement for one of these, I want to set the subject for that sentence to the same as the last sentence. So in this example, the subject would be 'Dog' for both sentences.

Answer: 
This solution has a little more flexibility to handle pluralization, pronoun selection as well as finding pronouns that may not be the first word of the sentence.

This likely extends past your scope since then you will get into verb tense issues, but I thought it might be helpful for others.

```
sentence_list = ['Dogs are great', 'They are so awesome', 'Cats are nice', 'They can be dangerous',
                 'On the lonely roads, they can be found.', 'He is fluffy.']
new_list = []
pronowns = ['they', 'them', 'she', 'her', 'he', 'him', 'us', 'we', 'it']
plurals = ['they', 'them', 'us', 'we']
last_subject = 'Dog'

for i, sentence in enumerate(sentence_list):

    # update last subject
    if 'Dog' in sentence:
        last_subject = 'Dog'
    elif 'Cat' in sentence:
        last_subject = 'Cat'

    if 'dog' not in sentence.lower() and 'cat' not in sentence.lower():
        # find pronoun
        for pn in pronowns:
            if pn in sentence.lower():
                # if it a plural usage add s
                if pn in plurals:
                    sentence_list[i] = sentence.lower().replace(pn, last_subject + 's')
                else:
                    sentence_list[i] = sentence.lower().replace(pn, last_subject)
                break

print(sentence_list)

```

Output:

```
['Dogs are great', 
'Dogs are so awesome', 
'Cats are nice', 
'Cats can be dangerous', 
'on the lonely roads, Cats can be found.', 
'Cat is fluffy.']

```
I may suggest you to use `startswith()` string method to check if a sentence starts with "They" or "It" for example, and then perform the substitution with the subject of the previous sentences. It is very simple and will probably fail on complex sentences, but it does the job for your question: 

```
sentence_list=['Dogs are great', 'They are so awesome','Cats are nice', 'They can be dangerous']

for i,sentence in enumerate(sentence_list):
    if sentence.startswith('Dogs'):
        subject= 'Dogs'
    elif sentence.startswith('Cats'):
        subject='Cats'
    if sentence.startswith('They'):
        sentence_list[i] = sentence.replace('They', subject)

print(sentence_list)
# ['Dogs are great', 'Dogs are so awesome', 'Cats are nice', 'Cats can be dangerous']

```