How to Check If a Value Counts as True or False in Python with bool()
if items: and if name: work in Python even though items is a list and name is a string, because every value counts as either true or false. bool() shows you which. This guide tests seven common values, with real output from Python 3.15.2.
Syntax
bool(<value>)
| Part | What it means |
|---|---|
<value> | Any value: a number, a string, a list, None and so on |
| The result | True or False, the same answer if <value>: would act on |
Python's documentation for bool: "Return a Boolean value, i.e. one of True or False. The argument is converted using the standard truth testing procedure." That procedure, truth value testing, lists the values that are false: "constants defined to be false: None and False", "zero of any numeric type", and "empty sequences and collections".
Prerequisites
- uv and Python. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with
uv init.
Step 1: Write the Script
for value in [1, 0, "yes", "", [3], [], None]:
print(repr(value), "->", bool(value))

- The list pairs each kind of value with its empty or zero version:
1and0,"yes"and"",[3]and[], plusNone. repr(value)prints the value as you'd write it in code, so the empty string shows as''.
Step 2: Run It
uv run python to_bool.py
1 -> True
0 -> False
'yes' -> True
'' -> False
[3] -> True
[] -> False
None -> False

Each pair split the same way: the value with something in it is True, its zero or empty version is False, and None is False. That's why if items: means "if the list isn't empty".
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Converting text like "False" with bool() | bool("False") is True: any non-empty string is true | Compare the text: text == "true" |
Expecting bool("0") to be False | It's True: "0" is a non-empty string | Convert to a number first: bool(int("0")) |
| Expecting a string of spaces to be false | bool(" ") is True | Strip it first: bool(text.strip()) |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
A setting read from a file or form is always True | The text was passed to bool() | Compare the text with the words you accept |
FAQ
Is 0.0 false too?
Yes: bool(0.0) is False. The documentation counts "zero of any numeric type" as false.
Do I need bool() inside an if?
No. if value: already tests the value this way. Use bool() when you want to keep or print the result.
Conclusion
bool() showed the rule behind if value:: 1, "yes" and [3] are true, while 0, "", [] and None are false.
Additional Resources
- bool — the built-in function.
- Truth Value Testing — every value Python counts as false.
