You can list empty or not using the length of the list in Python.
l2 =  if l2: print("the list is not empty") else: print("the list is empty")
Output: the list is empty
But it will not work in a different type of list
a =  a = [, ] a = [, , [, ]]
Python check if the list/sublist is not empty Example
Simple example code used a function that recursively checks the items within sublists:
def is_empty(l): return all(is_empty(i) if isinstance(i, list) else False for i in l) a =  print(is_empty(a)) a = [, ] print(is_empty(a)) a = [, , [, ]] print(is_empty(a))
Do comment if you have any doubts and suggestions on this Python List topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.