Iterating over dictionaries


#1

Ive made a function that a list of dictionaries, some will be empty and some will not.
Is there a way of iterating through the list to just get the dictionaries that are not empty?


#2

assuming this is python, what do you want to do with the dictionaries? Empty dictionaries evaluate to false where dictionary with context evaluate to True, so you could use this to your advantage


#3

I see what you mean, I'm struggling to word my question!
If I have a list of dictionaries, what I want to return is the numbers of the dictionaries from the left that have anything in them. I think this is the index of the dictionary but I could be wrong...


#4

simple:

counter = 0
for i in your_list:
    if i:
       counter += 1
    else:
        break