Use with AIif not a:
    print("List is empty")

Using the implicit booleanness of the empty list is quite Pythonic.

Answer from Patrick on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › how-to-check-if-a-list-is-empty-in-python
Python isEmpty() equivalent – How to Check if a List is Empty in Python
April 19, 2023 - You can use the len() function in Python to return the number of elements in a data structure.
🌐
CodeRivers
coderivers.org › blog › isempty-python
Mastering `isempty` in Python: Concepts, Usage, and Best Practices - CodeRivers
February 22, 2026 - In Python, checking whether a data structure is empty is a common operation. While there isn't a built-in isempty function in the core Python language for all data types, there are straightforward ways to achieve the same result. Understanding how to check for emptiness is crucial for writing robust and efficient code, especially when dealing with conditional logic, loops, and data processing.
🌐
Reddit
reddit.com › r/learnpython › stack isempty()
r/learnpython on Reddit: Stack isEmpty()
March 29, 2018 -

class Stack: def init(self): self.items = []

def isEmpty(self):
    return self.items == []

def push(self, item):
    self.items.append(item)

def pop(self):
    return self.items.pop()

def peek(self):
    return self.items[len(self.items)-1]

def size(self):
    return len(self.items)

Can anyone explain this to me how isEmpty() works. i dont get it how this statement return self.items == [] works when there is no if condition

🌐
GeeksforGeeks
geeksforgeeks.org › python › python-check-if-list-empty-not
Check if a list is empty or not in Python - GeeksforGeeks
October 24, 2024 - Lists can be directly evaluated in conditions. Python considers an empty list as False.
🌐
Medium
learnngrowit.medium.com › checking-if-a-stack-is-empty-or-not-in-python-4788314cba49
Checking if a Stack is Empty | Python | by Saurabh Mishra | Medium
April 7, 2023 - Checking if a Stack is Empty | Python Problem Write a function to check if a stack is empty or not. A stack is said to be empty if there are no elements in it. Example Suppose we have a stack s …
🌐
Reddit
reddit.com › r/learnpython › how do i check if this list is "empty"?
r/learnpython on Reddit: How do I check if this list is "empty"?
December 8, 2022 -

I'm completely stumped on a computer science assignment because our lecturer has given us zero information. We're supposed to have the user input a list and check if the list is in decreasing order and print a suitable message if it is. That part works fine. However, if the list is "empty" (I'll explain the quotations in a second) then it should print the list is empty.

The problem is that, according to our brief we're supposed to use .split(",") in order to allow the user to separate their numbers with commas. The problem lies in the fact that even if a user hits enter without inputting anything, the list is still '1' long with just an empty string. I've been scouring the web to find out how to check if a list is empty. But all the tutorials have so far just been in relation to actually empty lists (as in, list = []). One did use the all() function to check that all items in the list were strings, which did work and let me print that the list is empty, but broke the original function. Could someone please help me I'm tearing my hair out with this.

--

def checkOrder():

# checks, etc.

integer_list = []

listLength = len(integer_list)

increasing = 0

decreasing = 0

singleValue = 0

# Converting inputted numbers into a split list

userInput = input("Please enter your numbers seperated by a comma (,):")

inputtedStrings = userInput.split(",")

for number in inputtedStrings:

inputtedIntegers = int(number)

integer_list.append(inputtedIntegers)

# Enumerating list

for i, val in enumerate(integer_list[:-1]):

if val <= integer_list[i+1]:

increasing = 1

elif val >= integer_list[i+1]:

decreasing = 1

# Check for a single value

if len(integer_list) == 1:

singleValue = 1

if len(integer_list) == 1 and

print("The list is empty.")

if increasing == 1:

print("The numbers are in increasing order.")

elif decreasing == 1 or singleValue == 1:

print("The numbers are in decreasing order.")

checkOrder()

--

🌐
Curict
en.curict.com › item › 9a › 9a5983d.html
Checking if a Python list is empty - curict.com
In Python, an empty sequence (an empty list) is considered False, so you can use the if not operator to check if a list is empty.
Find elsewhere
🌐
PythonHow
pythonhow.com › how › check-if-a-string-is-empty
Here is how to check if a string is empty in Python
In Python, you can check if a string is empty by using the 'not' operator as shown in the code above.
🌐
Built In
builtin.com › articles › python-check-if-list-is-empty
Python Check if a List Is Empty: A Guide | Built In
There are a variety of methods that can be used to check if a list is empty in Python, including the Truth Value Testing method, the len() function and the == operator. Learn more.
🌐
Python.org
discuss.python.org › ideas
Os.path.isempty() & pathlib.Path.is_empty() - Ideas - Discussions on Python.org
April 5, 2024 - Currently there’s no way to safely delete or overwrite a file or folder without losing data. I propose a function that allows you to check for this: def isempty(path: StrOrBytesPath, *, follow_symlinks: bool = True) -> bool: """Test whether a file or directory is empty.""" if not follow_symlinks and (islink(path) or isjunction(path)): return True if isfile(path): return not getsize(path) if not isdir(path): return True return not listdir(path) Ad...
🌐
Medium
pavolkutaj.medium.com › how-to-check-if-a-list-dict-or-set-is-empty-in-python-as-per-pep8-35d8c64d07d0
How to Check if a List, Dict or Set is Empty in Python as per PEP8 | by Pavol Z. Kutaj | Medium
September 7, 2023 - in effect, it is saying that __nonzero__ is the interface for testing emptiness (__bool__ in python 3 → built-in bool())
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-check-if-variable-is-empty-in-python
How To Check If Variable Is Empty In Python? - GeeksforGeeks
July 23, 2025 - Handling empty variables is a common task in programming, and Python provides several approaches to determine if a variable is empty. Whether you are working with strings, lists, or any other data type, understanding these methods can help you write more robust and readable code.
🌐
Python Engineer
python-engineer.com › posts › check-if-list-is-empty
How to check if a List is empty in Python - Python Engineer
This is using the Truth Value Testing in Python, also known as implicit booleaness or truthy/falsy value testing.
🌐
Python Morsels
pythonmorsels.com › checking-for-an-empty-list-in-python
Checking for an empty list in Python - Python Morsels
July 18, 2026 - Python programmers typically check for empty lists by relying on truthiness.
🌐
Mimo
mimo.org › tutorials › python › how-to-check-if-a-list-is-empty-in-python
Mimo: The coding platform you need to learn Web Development, Python, and more.
Learn how to check if a list is empty in Python using truthiness or len(), guard before indexing, and avoid common mistakes.
🌐
Python Pool
pythonpool.com › home › how to › check if a list is empty in python: if not, len(), and numpy
Check if a List Is Empty in Python: if not, len(), and NumPy
July 13, 2026 - Quick answer: Use if not items: for an ordinary Python list. Use if items: for the non-empty case, len(items) == 0 when the count is part of the logic, and array.size == 0 for a NumPy array.