>>> if len(a)==0: print ("list is empty") else: print ("list is not empty")
if len(li) == 0: print('the list is empty')
if not a: print("List is empty")
if '' in list: # do stuff
For sequences, (strings, lists, tuples), use the fact that empty sequences are false. Yes: if not seq: if seq: No: if len(seq): if not len(seq):
# An empty list object evaluates to False a = [] not a # Output: # True