title: Logical expression in key of dictionary in Python
body: <p>As a simplified example, say I have the following if statement</p>
  
  <pre><code>if x &gt; 5:
      score = 1
  else if x &lt;= 5
      score = 2
  </code></pre>
  
  <p>How can I replace this with a dictionary? I want something like</p>
  
  <pre><code>score = {x &gt; 5: 1, x &lt;= 5: 2}[x]
  </code></pre>
  
  <p>My actual if statement is quite long, so I'd like to use this condensed construct.</p>