辞書内のリストから空白の値を削除するプログラムに取り組んでいますが、値全体が単一のスペースのみを保持する単一の配列で構成されている場合は、単一のスペースを含む要素を削除する必要があります。
def CleanWhiteSpace(theDict) :
stuff=[]
for key2 in theDict.keys():
for value2 in theDict.values():
if value2 == [' ']:
print key2
del theDict[key2]
print "hi"
print theDict
for key,value in theDict.iteritems():
for d in value:
print value
if d != ' ':
stuff.append(d)
theDict[key]=stuff
stuff=[]
return theDict
print CleanWhiteSpace({'a':['1','2'],'b':['3',' '],'c':[' ']})
これでキーcを削除するだけです。