Testing for an empty list

Cameron Laird claird at lairds.us
Thu Jul 3 22:02:29 EDT 2008


In article <mailman.37.1215119171.20628.python-list at python.org>,
Matthew Fitzgibbons  <elessar at nienna.org> wrote:
>Alexnb wrote:
>> Okay this is a simple question I just don't know how. If I have a list, say:
>> 
>> funList = []
>> 
>> and after a while something possible should have been appended to it, but
>> wasn't. How can I test if that list is empty.
>
>if not funList:
>	do_something()
			.
			.
			.
It's also perfectly legitimate--and arguably even more 
precise--to write

    if funList == []:
	do_something()



More information about the Python-list mailing list