Chrome Extension

Checking if List is empty in Python with Examples

Below are the different code examples that are used to check whether a List is empty or not in python.
fruit_list = []

# Using not keyword
if not fruit_list:
    print("List is empty")

# Using len() method
if len(fruit_list) == 0:
    print("List is empty")
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

You can also use '==' operator to check if a python list contains items or not. Below is the example to check an empty list with an equal operator.

fruit_list = []

if fruit_list == []:
    print("List is empty")

Search Index Data (The code snippet can also be found with below search text)

empty list check python
check if a list contains items or not
Was this helpful?