I have the following list:
['10.10.10.10', '20.20.20.20', '30.30.30.30', '10.20.30.40|locationInherited=true', '40.40.40.40', '8.8.8.8|locationInherited=true']
I need to remove all elements that contain '|locationInherited=true', so both '10.20.30.40|locationInherited=true' & '8.8.8.8|locationInherited=true' need to be removed so all that is left in the list is ['10.10.10.10', '20.20.20.20', '30.30.30.30', '40.40.40.40']
I have tried
for elem in list:
if '|locationInherited=true' in elem:
list.remove(elem)
And
while list.count('|locationInherited=true') > 0:
list.remove('|locationInherited=true')
Neither produce an error but neither remove all the necessary elements.