title: How to handle missing key in dictionary?
body: <p>I have a list of dictionary with keys and values. Unfortunately, some keys are not available for some dictionaries. E.g. year 1969 is not available. When I run the code, the output is stuck as there is no &quot;year&quot; key.
  How can I make the program continue with 1970 and so on?</p>
  <pre><code>testdict = [{&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1964},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1965},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1966},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1967},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1968},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1970},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1971},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1972},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1973},
              {&quot;brand&quot;: &quot;ford&quot;, &quot;model&quot;: &quot;Mustang&quot;, &quot;year&quot;: 1974},]
  
  for x in testdict:
      print(x[&quot;brand&quot;], x[&quot;year&quot;])
  </code></pre>
  <p>I am getting this output:</p>
  <pre class="lang-none prettyprint-override"><code>ford 1964
  ford 1965
  ford 1966
  ford 1967
  ford 1968
  
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-40-8175c2e2026a&gt; in &lt;module&gt;()
        1 for x in testdict:
  ----&gt; 2     print(x[&quot;brand&quot;], x[&quot;year&quot;])
  
  KeyError: 'year'
  </code></pre>
  <p>How to skip the values which are not present in the dictionary?</p>