VOOZH about

URL: https://www.geeksforgeeks.org/python/truthy-vs-falsy-values-in-python/

⇱ Truthy vs Falsy Values in Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Truthy vs Falsy Values in Python

Last Updated : 27 May, 2026

In Python, every value has an inherent Boolean evaluation, it can either be considered True or False in a Boolean context. Values that evaluate to True are called truthy and values that evaluate to False are called falsy.


Output
This will print because 7 is truthy.

Explanation:

  • 7 is a truthy value -> if number: evaluates to True.
  • 0 is a falsy value -> if number: evaluates to False, so nothing prints.

Truthy Values

These evaluate to True in a Boolean context:

  • Non-empty sequences or collections: [ 1 ], ( 0, ), "Hello", { 1:2 }
  • Numeric values not equal to zero: 1, -4, 3.5
  • Constant: True

Output
Non-empty list is truthy
-4 is truthy

Falsy Values

These evaluate to False in a Boolean context:

  • Empty sequences and collections: [ ], ( ), { }, set( ), " ", range(0)
  • Numbers: 0 (integer), 0.0 (float), 0j (complex)
  • Constants: None, False

Output
0 is falsy
Empty list is falsy

Example: This program demonstrates how truthy and falsy values can simplify conditions directly in the main code.


Output
7 is odd
4 is even

Explanation:

  • num1 % 2 calculates the remainder when num1 is divided by 2.
  • If remainder is 1 -> truthy -> the number is odd -> print "7 is odd".
  • If remainder is 0 -> falsy -> the number is even -> print "4 is even".
  • Same logic applies to num2.

Built-in bool() function

One can check if a value is either truthy or falsy with built-in bool() function. This function is used to return or convert a value to a Boolean value i.e., True or False, using the standard truth testing procedure.


Output
True
False
True
False
False

Explanation:

  • bool() converts any value to its Boolean equivalent.
  • Truthy values are converted to True, while falsy values are converted to False.
  • 7 and [1, 2, 3] are truthy, whereas 0, [] , and None are falsy.

Syntax:

bool(value)

Parameter: value any Python object or literal to test for truthiness.

Comment
Article Tags: