if not a:
print("List is empty")
Using the implicit booleanness of the empty list
is quite pythonic.
More Related Contents:
- How do i search for 2 of the same numbers in a list? (python) [closed]
- How do I clone a list so that it doesn’t change unexpectedly after assignment?
- Python append() vs. + operator on lists, why do these give different results?
- Why does Python skip elements when I modify a list while iterating over it?
- How to zip two differently sized lists, repeating the shorter list?
- Python list problem [duplicate]
- Count frequency of words in a list and sort by frequency
- How to define a two-dimensional array?
- Can’t modify list elements in a loop [duplicate]
- How do I make a flat list out of a list of lists?
- Calling filter returns [duplicate]
- Check if string ends with one of the strings from a list
- How to sort a list of tuples according to another list
- Can I create a “view” on a Python list?
- How to efficiently compare two unordered lists (not sets)?
- Converting Dictionary to List? [duplicate]
- Python AND operator on two boolean lists – how?
- Converting a list of tuples into a dict
- Python Array Slice With Comma?
- Find an element in a list of tuples
- How to convert list of tuples to multiple lists?
- Python: find closest string (from a list) to another string
- How to override the slice functionality of list in its derived class
- Print a list in reverse order with range()?
- How do I reverse a list using recursion in Python?
- Counting depth or the deepest level a nested list goes to
- Which is the most efficient way to iterate through a list in python?
- How does str.startswith really work?
- Best way to remove elements from a list
- All possible permutations of a set of lists in Python