What is Truthy and Falsy in python ? How is it different from True and False?
<p>I just came to know there are <strong>Truthy</strong> and <strong>Falsy</strong> values in python which are different from the normal <code>True</code> and <code>False</code>?</p>

<p>Can someone please explain in depth what <em>truthy</em> and <em>falsy</em> values are? </p>

<p>Where should I use them?</p>

<p>What is the difference between <em>truthy</em> and <code>True</code> values and <em>falsy</em> and <code>False</code> values ?</p>

<p>As the comments described, it just refers to values which are evaluated to True or False.</p>

<p>For instance, to see if a list is not empty, instead of checking like this:</p>

<pre><code>if len(my_list) != 0:
   print "Not empty!"
</code></pre>

<p>You can simply do this:</p>

<pre><code>if my_list:
   print "Not empty!"
</code></pre>

<p>This is because some values, such as empty lists, are considered False when evaluated for a boolean value. Non-empty lists are True.</p>

<p>Similarly for the integer 0, the empty string "", and so on, for False, and non-zero integers, non-empty strings, and so on, for True.</p>

<p>The idea of terms like "truthy" and "falsy" simply refer to those values which are considered True in cases like those described above, and those which are considered False.</p>

<p>For example, an empty list (<code>[]</code>) is considered "falsy", and a non-empty list (for example, <code>[1]</code>) is considered "truthy".</p>

python