in and not in Operators

You can determine whether a value is in or not in a list . Returns True or False.

>>> spam = ['hello', 'hi', 'howdy', 'heyas']
>>> 'cat' in spam
False
>>> 'howdy' not in spam
False
>>> 'cat' not in spam
True

You can also use the in and not operators to check if a key or value exists in a dict .

>>> spam = {'name': 'Zophie', 'age': 7}
>>> 'name' in spam.keys()
True
>>> 'Zophie' in spam.values()
True
>>> 'color' in spam.keys()
False
>>> 'color' not in spam.keys()
True
>>> 'color' in spam
False

Note, the last 'color' in spam style short-hand always checks the if it exists as a key.