Question
Asked By – y2k
The API I’m working with can return empty []
lists.
The following conditional statements aren’t working as expected:
if myList is not None: #not working
pass
if myList is not []: #not working
pass
What will work?
Now we will see solution for issue: How to check if a list is empty in Python? [duplicate]
Answer
if not myList:
print "Nothing here"
This question is answered By – Marek Karbarz
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0