The pythonic way to check if a dictionary
is empty is using the not
operator.
my_dict = {}
if not my_dict:
print("My dictionary is empty!!!")
To check the opposite, if the dict is not empty:
my_dict = {1:'amazon', 2:'microsoft'}
if my_dict:
print("My dict is NOT empty!!!")