title: Ternary Operator with a dictionary [python]
body: <p>I want to optimize the code below to a <strong>one line</strong></p>
  <pre><code>if i == 0:
      d = {}
  else:
      d[j] = d.get(j, 0) + 1
  </code></pre>
  <p>i tried solving it using a ternary operator but it gave me an error</p>
  <pre><code>d = {} if i == 0 else d[j] = d.get(j, 0) + 1
  </code></pre>
  <p><strong>The error :</strong></p>
  <blockquote>
  <pre><code>d = {} if i == 0 else d[j] = d.get(j, 0) + 1
          ^
  SyntaxError: cannot assign to conditional expression
  </code></pre>
  </blockquote>
  <p>Can it be solved using ternary operator or is there another way to make it in a <strong>one line</strong>?</p>