In [1]:
d = {'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}
In [2]:
print('key1' in d)
In [3]:
print('val1' in d)
In [4]:
print('key4' not in d)
In [5]:
print(d['key1'])
In [6]:
# print(d['key4'])
# KeyError: 'key4'
In [7]:
print(d.get('key4'))
In [8]:
print('val1' in d.values())
In [9]:
print('val4' not in d.values())
In [10]:
print(('key1', 'val1') in d.items())
In [11]:
print(('key1', 'val2') in d.items())
In [12]:
print(('key1', 'val2') not in d.items())