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 write a slide puzzle game with Python and Pygame (2020 tutorial)

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

Introduction to multitasking with Python #001 multithreading (2020 tutorial)