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
Post a Comment