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

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -