I read a csv file, using DictReader.
I have a list of dictionaries:
eg:
a = [{'Name':'A','Class':'1'},{'Name':'B','Class':'1'},{'Name':'C','Class':'2'}]
I want to count the number of entries in the list that have 'Class' == 1.
Is it possible to do it without a loop?
EDIT:
I have tried the following:
count = 0
for k in a:
if k['Class'] == '1':
count += 1
print(count)