title: Python how to check if variable exist and its length, in one if statement?
body: <p>Here's my situation:</p>
  
  <pre><code>if var:
      if len(var) == 5:
          do something...
  else:
      do the same thing...
  </code></pre>
  
  <p>To avoid repeating the same piece of code, I would like to combine those 2 if conditions, in one. But if var is None, I can't check its length... Any idea? 
  I would like something like this:</p>
  
  <pre><code>if var and len(var) == 5:
      do something...
  </code></pre>