Last modified: Mar 13, 2026 By Alexander Williams

List of Booleans Python Guide & Examples

Python lists are versatile. They can hold any data type. This includes Boolean values. A list of Booleans contains only True and False values.

These lists are powerful tools. They are used for data filtering, condition checks, and logic operations. This guide explains how to create and use them effectively.

What is a Boolean in Python?

Before diving into lists, understand Booleans. In Python, bool is a basic data type. It has only two possible values: True and False.

These values are the result of comparison or logical operations. They are fundamental to controlling program flow with if statements and loops. For a deeper dive, see our guide on Python Booleans Guide: True, False, Logic.

Creating a List of Booleans

You create a Boolean list like any other list. Use square brackets and separate values with commas.


# Creating a list of Booleans
bool_list = [True, False, True, True, False]
print(bool_list)
print(type(bool_list))
    

[True, False, True, True, False]
<class 'list'>
    

You can also generate Boolean lists dynamically. Use list comprehension or functions like map().

Common Use Cases for Boolean Lists

Boolean lists are not just for storage. They drive logic and data processing.

1. Filtering Data

This is the most common use. A Boolean list acts as a mask. You use it to select items from another list.


# Original data list
scores = [85, 42, 90, 55, 78]
# Boolean list representing pass/fail (score >= 60)
passed = [score >= 60 for score in scores]
print("Pass/Fail Mask:", passed)

# Filter to get only passing scores
passing_scores = [scores[i] for i in range(len(scores)) if passed[i]]
print("Passing Scores:", passing_scores)
    

Pass/Fail Mask: [True, False, True, False, True]
Passing Scores: [85, 90, 78]
    

This technique is central to data analysis. It's a precursor to using more advanced structures like Python Boolean Arrays in libraries like NumPy.

2. Tracking States or Conditions

Boolean lists can track multiple conditions over time. Imagine monitoring system statuses.


# Track if servers are online
server_status = [True, True, False, True]
server_names = ["Web", "DB", "Cache", "API"]

for i, status in enumerate(server_status):
    state = "ONLINE" if status else "OFFLINE"
    print(f"Server '{server_names[i]}' is {state}")
    

Server 'Web' is ONLINE
Server 'DB' is ONLINE
Server 'Cache' is OFFLINE
Server 'API' is ONLINE
    

3. Performing Logical Operations

You can apply logic to entire Boolean lists. Use the built-in all() and any() functions.

The all() function returns True only if every element in the iterable is True.


checklist_1 = [True, True, True, True]
checklist_2 = [True, False, True, True]

print("All tasks done in list 1?", all(checklist_1))
print("All tasks done in list 2?", all(checklist_2))
    

All tasks done in list 1? True
All tasks done in list 2? False
    

The any() function returns True if at least one element is True.


alerts = [False, False, True, False]
print("Is there any alert active?", any(alerts))
    

Is there any alert active? True
    

Generating Boolean Lists from Data

You rarely type Boolean lists manually. You create them from existing data.

Using List Comprehension

This is the most Pythonic way. It's concise and readable.


numbers = [10, 20, 30, 40, 50]
# Create a Boolean list: True for numbers > 25
is_large = [n > 25 for n in numbers]
print(is_large)
    

[False, False, True, True, True]
    

Using the map() Function

The map() function applies a function to every item in a list. It's useful for simple transformations.


def is_even(x):
    return x % 2 == 0

numbers = [1, 2, 3, 4, 5]
even_mask = list(map(is_even, numbers))
print(even_mask)
    

[False, True, False, True, False]
    

Important Tips and Best Practices

Keep your code clean and efficient.

Use meaningful variable names. Names like is_active or passed_tests are better than bool_list.

Leverage built-in functions. Don't write loops to check if all values are True. Use all().

Understand truthy and falsy values. In Python, non-Boolean values can be evaluated in a Boolean context. For example, empty lists are falsy. This is a core concept covered in Python Booleans: True, False, Logic Explained.


# Be careful: This is a list of integers, not Booleans!
my_list = [1, 0, 10, -5]
# In a Boolean context (like an if statement), they are truthy/falsy
if my_list[1]: # This checks if 0 is True. 0 is falsy.
    print("This won't print.")
    

Conclusion

Lists of Booleans are simple yet powerful. They bridge raw data and logical decision-making in your code.

You can use them to filter datasets, track system states, and evaluate multiple conditions at once. Mastering their creation with list comprehension and their analysis with all() and any() is a key Python skill.

Start by using them for basic data masking. Then, explore how they form the foundation for more complex operations in data science libraries. They are a fundamental tool for writing clear, logical, and efficient Python programs.