How do I check if a list is empty?

Spread the love

In this article, you will how do I check if a list is empty?

#example program – 1

b=[] if((len(b))==0): print("list is empty") else: print("list contains elements")

Output:

#example program 2

b=[] if not b: print("List is empty")

Output: