[Tutor] Empty list validation
srilyk at gmail.com
Mon Jun 9 16:54:42 CEST 2008
>>> def empty_or_not(mylist):
... if mylist:
... print "Not empty"
... elif not mylist:
... print "Empty!"
>>> foo = 
My guess is that if any object is empty, it's considered "not".
On Mon, Jun 9, 2008 at 9:25 AM, qsqgeekyogdty at tiscali.co.uk
<qsqgeekyogdty at tiscali.co.uk> wrote:
> Sorry if this is a basic question, but how do I check if list is empty
> or not and return True or False ;)
> Tutor maillist - Tutor at python.org
To be considered stupid and to be told so is more painful than being
called gluttonous, mendacious, violent, lascivious, lazy, cowardly:
every weakness, every vice, has found its defenders, its rhetoric, its
ennoblement and exaltation, but stupidity hasn't. - Primo Levi
More information about the Tutor