Use the in
operator:
if b in a:
Demo:
>>> a = {'foo': 1, 'bar': 2}
>>> 'foo' in a
True
>>> 'spam' in a
False
You really want to start reading the Python tutorial, the section on dictionaries covers this very subject.
Use the in
operator:
if b in a:
Demo:
>>> a = {'foo': 1, 'bar': 2}
>>> 'foo' in a
True
>>> 'spam' in a
False
You really want to start reading the Python tutorial, the section on dictionaries covers this very subject.