I have a multiple dicts in the list. I want to count the number of occurances of the certain value from the list of dicts.
Here's the list of dict:
a = [{"a":"data1","b":"Nill","c":"data3","d":"Nill"},{"a":"dat1","b":"dat2","c":"dat3","d":"Nill"},{"a":"sa1","b":"sa2","c":"sa3","d":"Nill"}]
In here, i want to count the occurance of Nill
in the Key. How to make it possible.
Here's the code i tried:
from collections import Counter
a = [{"a":"data1","b":"Nill","c":"data3","d":"Nill"},{"a":"dat1","b":"dat2","c":"dat3","d":"Nill"},{"a":"sa1","b":"sa2","c":"sa3","d":"Nill"}]
s = 0
for i in a:
d = (a[s])
#print(d)
q = 0
for z in d:
print(z)
z1=d[z]
#print(z)
if z1 == "Nill":
q = q+1
co = {z:q}
print(co)
Expected Output:
The count of Nill
values in the list of dict
{a:0,b:1,c:0,d:3}