'How can you filter a list of dictionary in python with list as value

#List of dictionary

List_of_dict = [
    {'id': 1,'Name':Tom, 'Data':[10,20,30,40,50],'Value':[1,2,3,4,5] },
    {'id': 2,'Name':Jack, 'Data':[10,20,30,],'Value':[3,4] },
    {'id': 3,'Name':Nancy, 'Data':[10,20],'Value':[3,4,5] },
    {'id': 4,'Name':Jack, 'Data':[20,],'Value':[1]}
]

Quest : Want to create a filter for data 30 and value 3 Expected - 1:

Output_dict = [{'id': 1,'Name':Tom, 'Data':[10,20,30,40,50],'Value':[1,2,3,4,5] },{'id': 2,'Name':Jack, 'Data':[10,20,30,],'Value':[3,4]

used this >>

Output_dict = [out for out in List_of_dict if  out['Data'] == [30] and out['Value'] == [3] ]

I don't get desired output with above

Also how do I create filter for Data: 20' and Value:3 or 4 Expected - 2:

[{'id': 1,'Name':Tom, 'Data':[10,20,30,40,50],'Value':[1,2,3,4,5] },{'id': 2,'Name':Jack, 'Data':[10,20,30,],'Value':[3,4] },{'id': 3,'Name':Nancy, 'Data':[10,20],'Value':[3,4,5] }]


Solution 1:[1]

You are testing against lists that have no match in your data.

Use e.g.

Output_dict = [out for out in List_of_dict if  30 in out['Data'] and 3 in out['Value']]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul Whipp