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 check if a string contains a substring in Python

How to use Python conditional expression?(Python Conditional Expression)

How to create a box pusher game with Python and Pygame Source Code (2020)