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 won't have access to **`collections.Counter`**, but **`collections.defaultdict`** was added in Python 2.5

**`keys`** and flatten list

```
data = [j for i in data for j in i.keys()]

# ['a', 'b', 'a', 'c', 'c', 'b', 'a', 'c', 'a', 'd']

```

**`collections.defaultdict`**

```
from collections import defaultdict
dct = defaultdict(int)

for key in data:
  dct[key] += 1

# defaultdict(<type 'int'>, {'a': 4, 'c': 3, 'b': 2, 'd': 1})

```

If you only need the count for `a`, there are simpler ways to do this, but this will give you the counts of all keys in your list of dictionaries.
A one-line solution could be:

`len([k for d in data for k in d.keys() if k == 'a'])`