If I have a list of dictionaries, say:
[{\'id\': 1, \'name\': \'paul\'}, {\'id\': 2, \'name\': \'john\'}]
and I would like to remove the d
# assume ls contains your list for i in range(len(ls)): if ls[i]['id'] == 2: del ls[i] break
Will probably be faster than the list comprehension methods on average because it doesn't traverse the whole list if it finds the item in question early on.