---
title: "How do I check if a list is empty in Python?"  
description: "How do I check if a list is empty in Python?"  
author: "Revati S Misra"  
published: 2023-04-27  
updated: 2023-05-01  
canonical: https://www.mindstick.com/forum/158051/how-do-i-check-if-a-list-is-empty-in-python  
category: "python"  
tags: ["python", "python 2"]  
reading_time: 2 minutes  

---

# How do I check if a list is empty in Python?

How do I [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) a list is empty in [Python](https://www.mindstick.com/articles/75378/simple-yet-useful-tips-when-using-python)?

## Replies

### Reply by Aryan Kumar

In Python, you can [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) if a list is empty using the built-in **len()** function, or by checking the boolean value of the list itself. Here are two examples:

```python
my_list = []  # An empty list
# Method 1: Using the len() function
if len(my_list) == 0:
   print("The list is empty")
# Method 2: Checking the boolean value of the list
if not my_list:
   print("The list is empty")
```

In the first example, the **len()** function is used to check the length of the list. If the length is equal to 0, then the list is empty.

In the second example, the boolean value of the list is checked. An empty list has a boolean value of **False**, so the **not** operator is used to check if the list is empty.

Both methods are equivalent, and you can use whichever method you prefer.

### Reply by Gulshan Negi

Hello this is Gulshan Negi

Well, using Python's built-in len() function or the list's boolean value, you can determine whether a list is empty.

Here's an example using the len() function:

```plaintext
my_list = []
if len(my_list) == 0:
   print("The list is empty")
else:
   print("The list is not empty")
```

Hope it will work for you

Thanks

### Reply by Krishnapriya Rajeev

We can use the Pythonic method of checking if a list is empty using its implicit booleanness. This is shown below in the case of an empty list:

```plaintext
list = []
if list:
	print('List is not empty!')
else:
	print('List is empty!')

# Output: List is empty!
```

If the list is not empty:

```plaintext
list = ['hello','world']
if list:
	print('List is not empty!')
else:
	print('List is empty!')

# Output: List is not empty!
```


---

Original Source: https://www.mindstick.com/forum/158051/how-do-i-check-if-a-list-is-empty-in-python

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
