Possible Duplicate:
How do you check if list is blank?
def CleanWhiteSpace(theDict) :
stuff=[]
for key,value in theDict.items():
for 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':[]})
how do u check is c is blank is c is simply equal to []?
okay I have a DICTIONARY that has LISTS inside it, some of these lists are composed of NOTHING. I need to loop though the dictionary and remove those keys that have the value of AN EMPTY LIST.
trying to be as clear as possible. what have i tried? i have tried multiple different methods to check if the value of the key is equal to nothing. i tried the value == "": statement, i tried the, len function to check if the value is empty, i tried if value: nothing seems to work, why? because as someone answered, empty lists don't get executed in the body of the loop