title: Best way to count char occurences in a string
body: <p>Hello I am trying to write these python lines in a single line but getting some errors due to the dictionary modifications the code is doing.</p>
  
  <pre><code>for i in range(len(string)):
      if string[i] in dict:
          dict[string[i]] += 1
  </code></pre>
  
  <p>the general syntax I believe is </p>
  
  <pre><code>abc = [i for i in len(x) if x[i] in array]
  </code></pre>
  
  <p>Would it be possible for someone to tell me how this might work considering that I am adding 1 to the value in a dictionary</p>
  
  <p>Thanks</p>