PLAY FREE ▸
Snekcade › Python guides › Booleans and truthiness
PYTHON FOR BEGINNERS · LOOP LAGOON

Python booleans: True, False and truthiness

The two values behind every if and while: comparisons, and/or/not, bool() and the surprise of True + True.

6 min read · updated December 2026

A boolean is the simplest value in Python. It has only two options: True or False. Every if and every while runs on booleans, so once you understand them, conditions stop feeling like magic. This guide covers comparisons, and/or/not, bool(), truthy and falsy values, and the strange fact that True + True is 2.

Want the basics of conditions first? Read if, elif and else, then come back.

TRUE AND FALSE

alive = True
has_key = False
print(alive, has_key)
print(type(alive))
True False
<class 'bool'>

The type is called bool. Both words start with a capital letter. true in lowercase is just an unknown name, and Python stops with a NameError.

COMPARISONS GIVE YOU BOOLEANS

You rarely type True by hand. Most booleans come from a comparison:

score = 120
print(score > 100)
print(score == 50)
print(score != 50)
print("a" in "snake")
True
False
True
True

The result is a normal value. You can store it in a variable with a clear name, which makes the if line read like English:

hp = 0
is_dead = hp <= 0
if is_dead:
    print("Game over")
Game over

AND, OR, NOT

has_key = True
door_locked = True
print(has_key and door_locked)
print(has_key or False)
print(not door_locked)
True
True
False

Python stops as soon as it knows the answer. In False and ... the right side is never even checked. This is called short-circuiting, and it lets you write safe checks like if items and items[0] == "gem":, which never touches items[0] when the list is empty.

BOOL() AND TRUTHY OR FALSY VALUES

Every value in Python can act as a boolean. bool(x) tells you which way it goes. These are falsy, they count as False:

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

Zero, empty text, empty collections and None. That is the whole list you need to remember. Everything else is truthy:

print(bool(-1), bool("hi"), bool([0]), bool(" "))
True True True True

A list with one zero inside is not empty, so it is truthy. A string with one space is not empty either. This is why if name: is the short way to ask "did the player type anything?"

WHAT DOES THIS PRINT?
print(bool("False"))
The text "False" is a string with five letters. It is not empty, so it is truthy. bool() does not read the word, it only checks if the string is empty.

BOOLEANS ARE SECRETLY NUMBERS

Under the hood, True is 1 and False is 0. So you can do math with them:

print(True + True)
print(True * 10)
print(False + 5)
2
10
5

It looks like a party trick, but it is useful. sum() over a list of comparisons counts how many are true:

rolls = [6, 2, 6, 4, 6]
sixes = sum(r == 6 for r in rolls)
print(sixes)
3

WHAT AND AND OR REALLY RETURN

Here is a surprise: and and or do not always give back True or False. They give back one of the two values. or returns the first truthy one, which is a neat way to set a default:

name = ""
player = name or "Player 1"
print(player)
print(0 or "zero")
print(3 and 5)
Player 1
zero
5

Inside an if this makes no difference, because the value is checked for truthiness anyway. It only matters when you print or store the result.

WHAT DOES THIS PRINT?
checks = [5 > 3, "" == " ", not False, 2 in [1, 2]]
print(sum(checks))
5 > 3 is True, "" == " " is False (one is empty, one has a space), not False is True and 2 in [1, 2] is True. Three Trues add up to 3.

ANY() AND ALL()

When you have many checks, two built-in functions save you a long and/or chain:

hp = [30, 0, 12]
print(any(h == 0 for h in hp))
print(all(h > 0 for h in hp))
True
False

COMMON BEGINNER MISTAKES

Lowercase true or false. Python needs True and False with a capital letter, otherwise you get NameError.
Writing if x == 1 or 2:. Python reads it as (x == 1) or 2, and 2 is always truthy, so the if always runs. Write if x == 1 or x == 2:, or if x in (1, 2):.
Turning text into a boolean with bool(). bool("False") and bool("0") are both True. To read a yes/no answer from input(), compare the text: answer.lower() == "yes".
Writing if done == True:. It works, but if done: says the same thing and reads better. For the opposite, use if not done:.
x = 5
if x == 1 or 2:
    print("this always prints")
this always prints

QUICK CHEAT SHEET

WHAT NEXT?

Booleans are the fuel of every loop. See them in action in while loops, where the loop keeps going as long as a condition stays True, or put them to work in FizzBuzz.

PRACTICE IT, DON'T JUST READ IT

Loop Lagoon in Snekcade has you predict which conditions are True, fix broken checks and count wins with real Python on your phone. It is one of the two free worlds.

PLAY LOOP LAGOON ▸

FAQ

What is a boolean in Python?

A value that is either True or False. Its type is bool. Comparisons like 5 > 3 produce booleans, and if and while use them to decide what runs.

What are truthy and falsy values in Python?

Falsy values count as False in a condition: 0, 0.0, empty text, empty lists, dicts and sets, None and False itself. Everything else is truthy and counts as True.

Why is bool("False") True in Python?

bool() only checks whether a string is empty. "False" is a five-letter string, so it is truthy. To read a yes/no answer, compare the text instead, for example answer.lower() == "yes".

Why does True + True equal 2 in Python?

bool is a subclass of int: True behaves like 1 and False like 0. That is why sum() over a list of comparisons counts how many are True.