0

it's not duplicate don't close it I have a dictionary as

{a:[a,b,c,d,e,f],b:[a,b,c,e,g],c:[a,b,h]}

I need to print a list of all keys that their value contain [a,b,c]

so in my example, I expect the output to be :

[a,b]

and not c as it just contains a and b only I tried :

error = []
for key in sites.keys():
    if ("a" and "b" and "c") in sites[key]:
        error.append(sites[key])

but I got :

[a,b,c]

what can I do?

and it's not answered here: How to test multiple variables against a value?

cuz my case is I need all values in my list to be found not an or and I tried and but didn't work as I mentioned

  • Please explain what you do not understand about applying the cited duplicate to your case. Have you tried to trace the intermediate results of the expression? For instance, enter `("a" and "b" and "c")` into your interactive command line -- see what the value is. – Prune Aug 17 '20 at 23:01
  • do you mean something like this? `error = [k for k,v in sites.items() if all(['a' in v, 'b' in v, 'c' in v])]` – dsal3389 Aug 17 '20 at 23:36

0 Answers0