Search⌘ K
AI Features

Checking for Nothing

Explore how Python treats None and empty data structures like strings, lists, and tuples in conditional statements. Understand how to test for the absence of value, differentiate None from empty values, and apply these checks to control program flow. This lesson helps you write clear, effective conditionals by accurately evaluating 'nothing' in Python.

We'll cover the following...

Because we are talking about statements that evaluate to True, we probably need to cover what evaluates to False. Python has the keyword False which I’ve mentioned a few times. However an empty string, tuple or list also evaluates to False. There is also another keyword that basically evaluates to False which is called None. The None value is used to represent the absence of value. It’s kind of analogous to Null, ...