Question: I have a multi-dimensional list as like below

```
multilist = [[1,2],[3,4,5],[3,4,5],[5,6],[5,6],[5,6]]

```

How can I get below results fast:

```
[1,2]: count 1 times
[3,4,5]: count 2 times
[5,6]: count 3 times

```

and also get the unique multi-dimensional list (remove duplicates) :

```
multi_list = [[1,2],[3,4,5],[5,6]]

```

Thanks a lot.

Answer: 
You can use tuples which are hashable and [`collections.Counter`](https://docs.python.org/2/library/collections.html#collections.Counter):

```
>>> multilist = [[1,2],[3,4,5],[3,4,5],[5,6],[5,6],[5,6]]
>>> multituples = [tuple(l) for l in multilist]
>>> from collections import Counter
>>> tc = Counter(multituples)
>>> tc
Counter({(5, 6): 3, (3, 4, 5): 2, (1, 2): 1})

```

To get the set of elements you just need the keys:

```
>>> tc.keys()
dict_keys([(1, 2), (3, 4, 5), (5, 6)])

```
As @ReutSharabani suggested, you can use tuples as dictionary keys, and then convert back to lists for display purposes. The code below doesn't reply on `collections` (not that there's anything wrong with that).

```
multilist = [[1,2],[3,4,5],[3,4,5],[5,6],[5,6],[5,6]]
histogram = {}
for x in multilist:
    xt = tuple(x)
    if xt not in histogram:
        histogram[xt] = 1
    else:
        histogram[xt] += 1
for k,c in histogram.items():
    print "%r: count %d times" % (list(k),c)
print [list(x) for x in histogram.keys()]

```