Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Python: Checking if nested list is essentially empty

📅 2009-Oct-22 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ empty, lists, python ⬩ 📚 Archive

Also see: http://stackoverflow.com/questions/1593564

# Note: all([]) returns True

def isListEmpty(inList):
    if isinstance(inList, list):    # Is a list
        return all( map(isListEmpty, inList) )
    return False # Not a list

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧