title: Use of if else inside a dict to set a value to key using Python
body: <p>I am looking for a way to use if else condition in a dictionary to set a value to a key. Is there a way?</p>
  
  <p>The example below might help you understand what I want to do. This is not a functional Python code. Just an example to give you an idea. </p>
  
  <pre><code>age = 22
  di = {
      'name': 'xyz',
      if age&gt;=18:
          'access_grant': 'yes',
      else:
          'access_grant': 'no',
       }   
  </code></pre>