delete common dictionaries in list based on a value
- by pythoonatic
How would I delete all corresponding dictionaries in a list of dictionaries based on one of the dictionaries having a character in it.
data = [
{ 'x' : 'a', 'y' : '1' },
{ 'x' : 'a', 'y' : '1/1' },
{ 'x' : 'a', 'y' : '2' },
{ 'x' : 'b', 'y' : '1' },
{ 'x' : 'b', 'y' : '1' },
{ 'x' : 'b', 'y' : '1' },
]
For example, how would I delete all of the x = a due to one of the y in the x=a having a / in it? Based on the example data above, here is where I would like to get to:
cleaneddata = [
{ 'x' : 'b', 'y' : '1' },
{ 'x' : 'b', 'y' : '1' },
{ 'x' : 'b', 'y' : '1' },
]