data = [False, False, False]
try:
out = next(elt for elt in data if elt) # holds the value of first non-empty element
except StopIteration:
print("all elements are empty")
data = [[], [], [1], [2]]
try:
out = next(elt for elt in data if elt) # [1]
except StopIteration:
print("all elements are empty")