How do you check if list is blank?
Possible Duplicate:
Python: What is the best way to check if a list is empty?
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':[]})
I edited this because I need more help. How do you check if c
is blank? Is c
is simply equal to []
?
I've tried ==[]
and "[]"
and getting the length and == ""
, but nothing seems to work.
在python中,空列表的计算结果为False。
if not c:
print "The list is empty"
else:
print "The list is not empty"
链接地址: http://www.djcxy.com/p/22498.html
下一篇: 你如何检查列表是否空白?