How to check a list is empty or not in Python

 The pythonic way to do this is:

l = []

#A empty list is evalutated to False in Python.

if not l:

    print('list empty')



Comments

Popular posts from this blog

How to create a memory puzzle game with Python and Pygame (#005)

How to write a slide puzzle game with Python and Pygame (2020 tutorial)

Introduction to multitasking with Python #003 gevent (2020 tutorial)