I tested the list to see if it is empty or not. Usually I use len (list) == 0, and I vaguely remembered how I recently read that the correct way to check if a list is empty, whether it was True or false.
So, I tried the False list, and this returned False. Maybe I suggest using ==? No, it also returned a lie. list is True, returns false, like list == True.
Now I'm confused, so I do a quick google and end with: The best way to check if a list is empty
The main answer:
if not a: print "List is empty"
So, I search a little more and end up in the python manual, where 4.1:
Any object can be checked for true, for use in an if or while condition, or as an operand of the following Boolean operations. The following values ββare considered false:
any empty sequence, for example, '', (), [].
Now I am confused. If I test the list as if not a list, it works fine. But if the empty list is false, then why can't I just do if the list is False or if the list == False?
thanks
Jason white
source share