I have a .txt file called test1.txt which contains:
apple
P apple apple
P apple
Pbanana apple P apple apple apple
I split it into catagories based on the letter P using this code:
import re
Apple_split = open("test1.txt").read().split("P")
print(Apple_split_split)
I now wish to count the number of times the word apple occurs within each split. Hopefully coming out with an output such as 1, 2, 1, 1, 3 or something like that. Any help would be appreciated.