Question: I know this is a frequently asked question, however I do not have access to the Counter module as I'm using v2.6 of Python. I want to count the number of time a specific key appears in a list of dictionaries.

If my dictionary looks like this:

```
data = [{'a':1, 'b':1}, {'a':1, 'c':1}, {'b':1, 'c':1}, {'a':1, 'c':1}, {'a':1, 'd':1}]

```

How would I find out how many times "a" appears? I've tried using len, but that only returns the number of values for one key.

```
len(data['a'])

```

Answer: 
You can use list comprehension. 

```
data = [{'a':1, 'b':1}, {'a':1, 'c':1}, {'b':1, 'c':1}, {'a':1, 'c':1}, {'a':1, 'd':1}]
sum([1 for d in data if 'a' in d])

```

*Explanation:
First take the dictionary object from list data, check if key 'a' is present in the dictionary or not, if present, add 1 to the list. Then sum the new list.*
This question looks very much like a class assignment. Here is a simple bit of code that will do the job:

```
n=0
for d in data:
   if 'a' in d:
       n+=1
print(n) 

```

Here `n` is a counter, the `for` loop iterates through the list of dictionaries.
The `'a' in d` expression will return true if the key 'a' is in the dictionary d, in which case the counter n will be incremented. At the end the result is printed. I believe in Python 2.6 the brackets would be optional (I am using 3.6).