Pattern: Use of deprecated .has_key()
Issue: -
.has_key()
was deprecated in Python 2. It is recommended to use the in
operator instead.
my_dict = {'hello': 'world'}
if my_dict.has_key('hello'):
print('It works!')
my_dict = {'hello': 'world'}
if 'hello' in my_dict:
print('It works!')