How do I check if a list is empty in Python?
The Python style guide, PEP-8, recommends checking whether a list (or other sequence) is False to determine that it is empty. For example:
False
empty_list = [] if not empty_list: print("The list is empty.") Click to Copy