Himanshu SharmaSoftware engineer
Let’s talk

Python Tutorial · Lesson 14 of 70

Python None and truthiness: what counts as True or False

Understand Python's None value, which values are falsy, how truthiness works in conditions, and how to test for None safely with is None.

11 minData types and operatorsUpdated 14 November 2026

Awaiting technical review. This lesson is readable but not yet listed in search engines.

By the end of this lessonUse None to mean no value, list which values count as falsy, and test for None correctly.

After this lesson you can represent a missing value with None, and you will know which values Python treats as False when it makes a decision.

None means no value

Sometimes a program needs a name that exists but has nothing meaningful in it yet: a member who has not chosen a username, a score that has not been recorded, a search that found no match. Python's answer is None. It is a single special value, and it has its own type.

python
username = None
print(username)
print(type(username))
result
None
<class 'NoneType'>

None is not zero, not an empty string, and not False. It is a separate idea: "nothing here". That difference matters. A student with a mark of 0 has a real score. A student whose mark is None has not been marked at all.

Testing for None

Because there is only ever one None object, the correct test uses is, which checks for the same object:

python
result = None
print(result is None)
print(result is not None)
print(result == None)
result
True
False
True

The third line works, but it is not the accepted style, because a class can define == to behave oddly. Use is None and is not None and your code will always be correct.

Many operations return None to say "nothing to give you". The most surprising case is a function with no return statement. You will learn about functions soon, but you can already see the principle in print itself, which does its job and then hands back nothing:

python
shown = print("hello")
print(shown)
result
hello
None

Truthiness

An if statement, which you will meet in the next section, accepts any value as its condition, not just True or False. Python converts the value using fixed rules. A value that behaves like False is called falsy. Everything else is truthy. The falsy values are:

  • False and None
  • zero of any number type: 0, 0.0
  • empty text: ""
  • empty collections: [], (), {} and an empty set

Every other value is truthy, including the text "0", the text "False" and a list that holds one zero. You can ask Python directly with bool():

python
values = [0, 1, -3, 0.0, "", " ", "0", None, [], [0], {}]
for value in values:
    print(repr(value), "->", bool(value))
result
0 -> False
1 -> True
-3 -> True
0.0 -> False
'' -> False
' ' -> True
'0' -> True
None -> False
[] -> False
[0] -> True
{} -> False

The repr() function shows the value as you would type it in code, which makes the empty string and the single space easy to tell apart. The loop belongs to the next section, so treat it as a tool that repeats for each item.

Using truthiness in practice

Truthiness lets you write short checks. Instead of testing whether a list has any items by comparing its length with zero, you can test the list itself:

python
basket = []
if basket:
    print("Basket has items")
else:
    print("Basket is empty")

basket.append("pen")
if basket:
    print("Basket has items")
else:
    print("Basket is empty")
result
Basket is empty
Basket has items

The list method append is covered in the collections section. The point here is that an empty list is falsy and a list holding something is truthy.

A trap: zero is not None

Truthiness is convenient, but it can hide a bug when zero is a perfectly valid value. Compare these two checks on a score of zero:

python
score = 0
if not score:
    print("treated as missing")
if score is None:
    print("really missing")
else:
    print("score is", score)
result
treated as missing
score is 0

The first check wrongly calls a genuine score of zero missing. When zero, an empty string or an empty list are valid answers in your program, test with is None and leave truthiness for places where empty really does mean nothing.

Choosing how to signal a missing value

None is only one way to signal that something is missing. Some programs use an empty string, a zero or a special value such as minus one. The trouble is that these look like real data, so they can slip into a calculation unnoticed. None is better because it cannot be mistaken for a genuine answer: adding None to a number fails loudly instead of quietly giving a wrong total. When you design a function that might find nothing, returning None is a clear and honest choice, as long as the code that calls it checks the result before using it.

Common mistakes

  • Using == None. It usually works but is None is the correct form.
  • Treating zero like None. if not score also catches a real zero. Test is None when zero is allowed.
  • Thinking "False" or "0" is falsy. Any non-empty string is truthy.
  • Printing a function's result when it has no return value and being surprised by None.
  • Writing None in lowercase. Only None with a capital N works.

A video version of this topic is in the video course at /learn/python/.

Exercise

Create a variable nickname = "" and a variable middle_name = None. Print bool(nickname), then print whether middle_name is missing using is None. Finally print the nickname if it is not empty, otherwise print the word friend, using a single expression with or.

Show a possible answer
python
nickname = ""
middle_name = None
print(bool(nickname))
print(middle_name is None)
print(nickname or "friend")
result
False
True
friend

Key points

  • None is Python's way of saying there is no value here. It has its own type, NoneType.
  • Falsy values are False, None, zero of any numeric type, and empty strings and empty collections. Everything else is truthy.
  • bool(value) shows how Python sees any value in a condition.
  • Test for None with is None or is not None, not with ==.
  • Zero and None are different. A score of 0 is a real value, but a missing score is None.

Check yourself

1. Which of these is falsy?
2. What is the best way to check whether result holds None?
3. What does print(bool([])) show?
4. A function has no return statement. What does it give back?