Skip to content

Python list isEmpty | Example code

  • by

You can create your own isEmpty function to check check if a list is empty in Python. Use not operator with if statement.

Example code list isEmpty in Python

def isEmpty(v):
    if not v:
        return "List is empty"
    else:
        return "List is Not empty"


list1 = [1, 2, 3, 4]

print(isEmpty(list1))

Output:

Python list isEmpty

Do comment if you have any doubts and suggestions on this list topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *