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 340 views
1 answer 226 views
4 answers 466 views
466 views asked Apr 24, 2021 by avibootz
2 answers 322 views
2 answers 289 views
1 answer 279 views
...