How to current Date and time in python with example

This tutorial explains multiple ways to check List is empty or not

Empty List contains zero elements in size and is denoted as []

For example, an Empty list can be declared as follows

list=[]

In Real applications, Data comes from an API and returns a List.

Check List is empty or not

There are multiple ways we can check List is empty or not.

Here is an example

list=[];
if not list the:
print("Empty List")

Output:

Empty List
  • use a length of a list The len function returns the size of a list, Returns zero for an empty list.

Here is an example

if len(list) == 0:
print("Empty List")
  • use empty brackets compares

use == operator that compares an empty list

if list == []:
   print("Empty List")