If I have a list of dictionaries, say:
[{\'id\': 1, \'name\': \'paul\'}, {\'id\': 2, \'name\': \'john\'}]
and I would like to remove the d
You can try the following:
a = [{'id': 1, 'name': 'paul'}, {'id': 2, 'name': 'john'}] for e in range(len(a) - 1, -1, -1): if a[e]['id'] == 2: a.pop(e)
If You can't pop from the beginning - pop from the end, it won't ruin the for loop.