for x in strs:
    if x in new_strs:
        new_strs.append(new_strs[new_strs.index(x)])
else:
    new_strs.append(x)
print([id(y) for y in new_strs])
How do I make Python make all identical strings use the same memory?