Check if a dictionary contain data true of false, then send a response back

It depends what you mean by data. Is it any dict key? Is it a given dict key?

An empty dict is falsey in Python, so just calling all() on your list should tell you if every dict has at least one key-value pair:

>>> all( [ {1:2}, {'A':'B'} ] )
True
>>> all( [ {1:2}, {'A':'B'}, {}, {3:4}] )
False

If you want to check if a given key is present in every dict, you could combine a list comprehension with get.

Leave a Comment