my_list = list()
# Check if a list is empty by its length
if len(my_list) == 0:
pass # the list is empty
# Check if a list is empty by direct comparison (only works for lists)
if my_list == []:
pass # the list is empty
# Check if a list is empty by its type flexibility **preferred method**
if not my_list:
pass # the list is empty
if __name__ == '__main__':
n = 10
a = [[] for x in range(n)]
print(a) # [[], [], [], [], [], [], [], [], [], []]
# Python program to declare
# empty list
# list is declared
a = []
empty_lists = [ [] for _ in range(n) ]
list = list()
list = []
# There are two common methods to create an empty list
x = list()
print(len(x)) # Output: 0
y = []
print(len(x)) # Output: 0
lst = [None] * 10
# Python program to declare
# empty list
# list is declared
a = []
print("Values of a:", a)
print("Type of a:", type(a))
print("Size of a:", len(a))
fib = []
l_empty = []
print(l_empty)
# []
print(len(l_empty))
# 0
>>> num = []
>>> len(num)
0