python - How do you check if list is blank? -


possible duplicate:
python: best way check if list empty?

def cleanwhitespace(thedict):     stuff=[]      key,value in thedict.items():         d in value:             if value != " ":                 stuff.append(d)                     print d                 thedict[key]=stuff             if not value[d]:                 print value         stuff=[]     return thedict     print cleanwhitespace({'a':['1','2'],'b':['3',' '],'c':[]}) 

i edited because need more help. how check if c blank? c equal []?

i've tried ==[] , "[]" , getting length , == "", nothing seems work.

in python, empty list evaluates false.

if not c:    print "the list empty" else:    print "the list not empty" 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -