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:

list is empty

#example program 2

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

Output:

List is empty

 

admin

admin

Leave a Reply

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