dimanche 18 mars 2018

How to check if any of multiple values exist in python dictionary [duplicate]

This question already has an answer here:

I'm new to python programming. I need to check if any of the following numbers exist in my dictionary Here is the code I tried to write:

C = {'h1':0,'c1':0,'c2':0}
if (0 or 1 or -1) in C.values():
   print "Yes"
else:
   print "No"

This always prints "No". Can anyone help me with the syntax? Thank you so much in advance

Aucun commentaire:

Enregistrer un commentaire