I have a list
of key-value
pair in python
. A sample of this list is:
list_pairs = [{'text': 'Zen', 'value': 'Zen'}, {'text': 'Global', 'value': 'Global'}, {'text': 'Corporation', 'value': 'Corporation'}]
Now I have a string str1
and what I want to do is to match it with text
field of each key-value
pair and delete the one which matches. So if my string is Zen
then delete {'text': 'Zen', 'value': 'Zen'}
from the list.
I tried to do del list_pairs[str1]
but it throws error as list indices can only be integers and not str
.
How can I delete the items from my list of key-value pair?