Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to check if a list is empty

# For sequences, (strings, lists, tuples), use the fact that empty sequences are false:

# Correct:
if not seq:
if seq:

# Wrong:
if len(seq):
if not len(seq):
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #check #list #empty
ADD COMMENT
Topic
Name
5+6 =