Counting frequencies in two lists, Python
<p>I'm new to programming in python so please bear over with my newbie question...</p>

<p>I have one initial list (list1) , which I have cleaned for duplicates and ended up with a list with only one of each value (list2): </p>

<p>list1 = [13, 19, 13, 2, 16, 6, 5, 19, 20, 21, 20, 13, 19, 13, 16],</p>

<p>list2 = [13, 19, 2, 16, 6, 5, 20, 21]</p>

<p>What I want is to count how many times each of the values in "list2" appears in "list1", but I can't figure out how to do that without getting it wrong. </p>

<p>The output I am looking for is something similar to this: </p>

<p>Number 13 is represented 1 times in list1. 
........ Number 16 is represented 2 times in list1. </p>

<p>You don't need to remove duplicates. When you add to a dictionary, automatically, the duplicates will be considered as single values.</p>

<pre><code>list1 = [13, 19, 13, 2, 16, 6, 5, 19, 20, 21, 20, 13, 19, 13, 16]
counts = {s:list1.count(s) for s in list1}
print counts

{2: 1, 5: 1, 6: 1, 13: 4, 16: 2, 19: 3, 20: 2, 21: 1}
</code></pre>

python list frequency counting