How to check if a list is empty?

Possible duplicate:
Python: What is the best way to check if a pool 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 it is free c? Is it cjust equal []?

I tried ==[]and "[]"and got the length and == "", but nothing works.

+5
source share
1 answer

In python, an empty list is False.

if not c:
   print "The list is empty"
else:
   print "The list is not empty"
+3
source

All Articles