Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

check if array is empty python

a = []

if not a:
  print("List is empty")
Comment

how to check if an array is empty in python

How to check for empty array in python
Comment

Check if list is empty in Python Using the len() method

code
# empty list & non-empty list
empty_list = []
non_empty_list = [1, 2, 3, 4]

# check if list is empty
def check_list_empty(lst):
    if len(lst) == 0:
        print('The List is empty')
    else:
        print('The list is not empty')
        
# pass in the lists to check_list_empty
check_list_empty(empty_list)
check_list_empty(non_empty_list)

#Output
The list is empty
The List is not empty
Comment

PREVIOUS NEXT
Code Example
Python :: python 3.10.5 release date 
Python :: try finally return precedent 
Python :: MEDIANA EN PANDAS 
Python :: Implement a function word_list() that reads the 5_letter_words.txt file and returns a list of the words in the file. 
Python :: Access the Response Methods and Attributes in python Show redirections 
Python :: python update python 
Python :: python pass statement 
Python :: how to print out voice level in python 
Python :: scapy get packet destination port python 
Python :: Python Decorating Functions with Parameters 
Python :: pd drop a range of dates 
Python :: rich content field django ckeditor not showing bullets 
Python :: pypi cryptography 
Python :: PyQgis Spatial join y attribute 
Python :: how to change the title of the top bar in python 
Python :: binning continuous values in pyspark 
Python :: .text xpath lxml 
Python :: python datediff days 
Python :: visualising data with tsne 
Python :: como colocar uma variavel no print python 
Python :: how to print continuesly in the same line in python 
Python :: appropriate graph for dataset visualization 
Python :: Tree : Top View 
Python :: how to unpack the whole list without index them individually python 
Python :: python loop through specific angle 
Python :: hoow to print python 
Python :: python arcade sound 
Python :: shutil cut poython 
Python :: python change type of every element in a dictionary 
Python :: most valuable features in pandas model 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =