title: efficient way to count the element in a dictionary in Python using a loop
body: <p>I have a list of values. I wish to count during a loop the number of element for each class (i.e. 1,2,3,4,5)     </p>
  
  <pre><code>mylist = [1,1,1,1,1,1,2,3,2,2,2,2,3,3,4,5,5,5,5]
  mydict = dict()
  for index in mylist:
      mydict[index] = +1
  mydict
  Out[344]: {1: 1, 2: 1, 3: 1, 4: 1, 5: 1}
  </code></pre>
  
  <p>I wish to get this result</p>
  
  <pre><code>Out[344]: {1: 6, 2: 5, 3: 3, 4: 1, 5: 4}
  </code></pre>