How to check if a list is empty in Python

2 Answers

0 votes
lst = []

if not lst:
    print("Empty")
    
    

'''
run:

Empty

'''

 



answered Jan 11, 2021 by avibootz
0 votes
lst = []

if len(lst) == 0:
    print("Empty")
    
    

'''
run:

Empty

'''

 



answered Jan 11, 2021 by avibootz

Related questions

2 answers 344 views
1 answer 230 views
4 answers 471 views
471 views asked Apr 24, 2021 by avibootz
2 answers 326 views
2 answers 293 views
1 answer 285 views
...