Python bool() Function Explained

The bool() function converts a value to either True or False.

This is useful when you want to check whether a value counts as "true" or "false" in Python. Beginners often use bool() to understand how values behave in if statements and other conditions.

Quick answer

print(bool(0))
print(bool(1))
print(bool(""))
print(bool("hello"))
print(bool([]))
print(bool([1, 2, 3]))

Expected output:

False
True
False
True
False
True

Use bool(value) to convert a value to True or False. Empty and zero-like values become False. Most other values become True.

What bool() does

bool() converts a value into a Boolean result.

A Boolean value can only be one of these:

  • True
  • False

This is especially useful in conditions such as if statements.

You can also call bool() with no argument:

print(bool())

Output:

False

If you are new to Boolean values, see what a Boolean means in Python.

bool() syntax

The basic syntax is:

bool(value)

The value can be many different types, such as:

  • numbers
  • strings
  • lists
  • tuples
  • dictionaries
  • sets
  • other objects

If you do not pass any value, Python returns False.

Example:

print(bool(10))
print(bool("Python"))
print(bool())

Output:

True
True
False

Values that become False

Some values are treated as false in Python. These are often called falsy values.

Common examples:

  • 0
  • 0.0
  • ""
  • []
  • ()
  • {}
  • set()
  • None

Example:

print(bool(0))
print(bool(0.0))
print(bool(""))
print(bool([]))
print(bool(()))
print(bool({}))
print(bool(set()))
print(bool(None))

Output:

False
False
False
False
False
False
False
False

Values that become True

Many values become True. These are often called truthy values.

Common examples:

  • non-zero numbers
  • non-empty strings
  • non-empty lists
  • non-empty tuples
  • non-empty sets
  • non-empty dictionaries

Example:

print(bool(5))
print(bool(-2))
print(bool("hello"))
print(bool([1, 2, 3]))
print(bool((1, 2)))
print(bool({"name": "Sam"}))

Output:

True
True
True
True
True
True

One important example is this:

print(bool("False"))

Output:

True

Even though the text says "False", it is still a non-empty string, so Python treats it as True.

Using bool() in real code

You can use bool() in simple programs to make your code easier to understand.

Check whether a list has items

items = [10, 20, 30]
print(bool(items))

Output:

True

With an empty list:

items = []
print(bool(items))

Output:

False

Check whether a string is empty

name = ""
print(bool(name))

Output:

False
name = "Mia"
print(bool(name))

Output:

True

Convert a result before printing or storing it

username = "alex"
has_name = bool(username)

print(has_name)

Output:

True

This can be useful when you want a clear True or False value instead of checking the original value later.

Help understand conditions

Python already checks truthy and falsy values in conditions.

numbers = [1, 2, 3]

if numbers:
    print("The list is not empty")

Output:

The list is not empty

To learn more about conditions, see Python if statements explained.

Important beginner warning

A very common mistake is expecting bool() to understand the meaning of text.

It does not do that.

bool("False") returns True

print(bool("False"))

Output:

True

bool("0") returns True

print(bool("0"))

Output:

True

This happens because both values are non-empty strings.

bool() does not read the word and decide what it means. It only checks whether the value is empty or not.

This matters a lot when working with input(), because input() always returns a string.

Example:

user_value = input("Enter True or False: ")
print(bool(user_value))

If the user types False, the result will still be True, because "False" is not empty.

When you may not need bool()

In many if statements, you do not need to write bool() yourself.

Python already checks truthiness for you.

Instead of this:

my_list = [1, 2, 3]

if bool(my_list):
    print("List has items")

You can simply write:

my_list = [1, 2, 3]

if my_list:
    print("List has items")

Both examples work.

Using bool() is still helpful when:

  • you are learning how truthy and falsy values work
  • you want to store a real True or False value
  • you want to print the result clearly while debugging

If you want to inspect the type of a value, see Python type() function explained.

Common mistakes

Here are some common beginner mistakes with bool().

Expecting bool("False") to return False

This is one of the most common problems.

print(bool("False"))

Output:

True

Why? Because "False" is a non-empty string.

If you want to check the actual text, compare the string directly:

value = "False"
print(value == "True")

Output:

False

Using strings from input() and expecting automatic yes/no conversion

input() returns text, not real Boolean values.

value = input("Enter yes or no: ")
print(bool(value))

If the user types no, the result is still True because "no" is not empty.

A safer approach is to clean the text and compare it:

value = input("Enter yes or no: ").strip().lower()
print(value == "yes")

This gives True only when the user enters yes.

Confusing empty values with the actual value False

These are different:

  • False
  • 0
  • ""
  • []
  • None

They all become False with bool(), but they are not the same value.

You can check the type if needed:

value = []
print(type(value))
print(bool(value))

Output:

<class 'list'>
False

Using {} expecting an empty set

In Python, {} creates an empty dictionary, not an empty set.

print(type({}))

Output:

<class 'dict'>

To make an empty set, use:

print(type(set()))

Output:

<class 'set'>

Helpful debugging checks

If bool() gives a result you did not expect, these checks can help:

print(bool(value))
print(type(value))
print(value)
print(value == "True")
print(value.strip().lower())

These are useful for finding out:

  • what the value really is
  • whether it is a string
  • whether it contains spaces
  • whether it matches the text you expected

This is especially helpful when handling user input. You may also want to read how to convert user input to numbers in Python.

FAQ

What does bool() return in Python?

It returns either True or False.

What happens if I call bool() with no argument?

It returns False.

Why does bool("False") return True?

Because the string is not empty. Non-empty strings are True.

Does bool(0) return False?

Yes. Zero values are False.

Should I use bool() inside every if statement?

No. Python already treats many values as True or False in conditions.

See also