I want to find if the line consists plural words. If so, I want to change those words to singular words.
For example:
file1.txt
That bananas is yellow. They does taste good.
Expected_output.txt
That banana is yellow. They do taste good.
please help me.
I have tried using .re to delete 's' from the words. But it deletes every 's' in the file. I want to delete only 's' that is at the end of word. For example, 'sacks'. I want 'sack', but I got 'ack'. This is what I have tried.
with open('file1.txt') as file1:
file1 = file1.read()
test = re.sub('s', ' ', file1)
with open('file1.txt', 'w') as out:
out.writelines(test)