title: Why do we need an except block for the try/except in Python?
body: <p>I get what it does but I don't understand why we do it? Why are we trying to except something?</p>
  <p>For example:</p>
  <pre class="lang-py prettyprint-override"><code>    for i, value in enumerate(arr):
          try:
              result_dict[value] += 1
          except KeyError:
              result_dict[value] = 1
  
  </code></pre>
  <p>Why do I have to do except KeyError? I don't know why a KeyError is thrown. Why can't I just do</p>
  <pre><code>result_dict[value] += 1
  </code></pre>
  <p>in the first place?</p>
  <p>What goes inside the except block for any try/catch? I get the error has to be thrown but what condition has to do inside the except block?</p>
  <p>Sorry if my question is too dumb. I'm a beginner.</p>