If we talk about a more Pythonic way then “in” is preferred over has_key(). The advantage of “in” is it will work on any collection.
has_key() is removed in Python 3.x. It is only in Python 2.x which is used very less. Also, it is a dictionary method and only used with dictionaries.