I have a list of words like the following:
old_list = ['houses','babies','cars','apples']
The output I need is:
new_list = ['house','baby','car','apple']
In order to do this, I came up with a loop:
new_list1 = []
new_list2 = []
for word in old_list:
if word.endswith("ies"):
new_list1[:0] = [word.replace("ies","y")]
elif word.endswith("s"):
new_list2[:0] = [word.replace(' ','')[:-1]]
new_list = new_list1 + new_list2 # Order doesn't matter, but len(new_list) == len(old_list)
It's simply not working. I'm getting something like:
new_list = ['baby','house','babie','car','apple']
I'm sure I'm just doing one simple thing wrong but I can't see it. And I would use list.append() if there's an easy way to implement it.
Thanks!