Are you checking the list correctly?
Python’s built-in len() function can be used to determine whether or not a list is empty. If the length of the list is 0, it means that the list contains no elements. …
Python’s built-in len() function can be used to determine whether or not a list is empty. If the length of the list is 0, it means that the list contains no elements.
my_list = []
if len(my_list) == 0:
print("The list is empty!")
else:
print("The list has elements.")
If you run this code, “The list is empty!” will be printed because my_list is an empty list.
This method can be useful in various contexts such as checking if a user input is empty (like when prompting for a username), if there are no items to display on a website, and so forth.

AI Is Changing Software Development. This Is How Pros Use It.
Written for working developers, Coding with AI goes beyond hype to show how AI fits into real production workflows. Learn how to integrate AI into Python projects, avoid hallucinations, refactor safely, generate tests and docs, and reclaim hours of development time—using techniques tested in real-world projects.
