You could use a list comprehension like this:
something = [(key, value) for key, value in something if key != 'b']
However, it looks like you're trying to reinvent a dictionary for some reason. If it doesn't have to be ordered, just use a dictionary:
something = {
'a': 'digital-text',
'b': 'bbbbbbb',
'c': '1318913293',
'd': '1-3',
}
del something['b']
If it does need to be ordered, you can use collections.OrderedDict
rather than dict
:
from collections import OrderedDict
something = OrderedDict([
('a', 'digital-text'),
('b', 'bbbbbbb'),
('c', '1318913293'),
('d', '1-3')
])
del something['b']
With a dictionary, if you need it back in the format you have in your question, just call items()
on the dictionary.
>>> # assuming something is an OrderedDict and you've already deleted the item
>>> # if it was a plain dict, it might be in a different order
>>> # if you haven't deleted the item, it would still be there
>>> something.items()
[('a', 'digital-text'), ('c', '1318913293'), ('d', '1-3')]
Additionally, to convert a list like in your question into some kind of dictionary, just pass it into it:
>>> dict([
... ('a', 'digital-text'),
... ('b', 'bbbbbbb'),
... ('c', '1318913293'),
... ('d', '1-3')
... ])
{'a': 'digital-text', 'b': 'bbbbbbb', 'c': '1318913293', 'd': '1-3'}