title: Python append to non-existing dict entry
body: <p>I have a dict where the keys map to arrays, like so:</p>
  <pre><code>{&quot;A&quot;: [...], &quot;B&quot;: [...], ...}
  </code></pre>
  <p>In a reducer function of mine I'd like to append to the value of a key, and set the key if it doesn't exist. Is there a clean way of doing this in a one-liner?</p>
  <p>I was thinking of the following, JavaScript-style:</p>
  <pre><code>dict[key] = dict.get(key, []).append(val)
  </code></pre>
  <p>But forgot that .append doesn't return the list itself like a functional language would do. So the only way I see now is to have a dumb if loop check if the key exists, and create it if not... Is there a cleaner way? Thanks</p>