[EMAIL PROTECTED] ha scritto:

Sorry if this is a basic question, but how do I check if list is empty or not and return True or False ;)

Normally, in Python, there are these evaluation:

1) True == 1
2) False == 0
3) Empty or have not value == False == 0
4) Not empty or have value == True == 1

So, consider this example:

>>> def isEmpty(l):
        if l:
                print "The list is NOT empty!"
        else:
                print "The list is empty!"

                
>>> list = []
>>> isEmpty(list)
The list is empty!
>>> list = ['hi']
>>> isEmpty(list)
The list is NOT empty!
>>>

HTH,
Simone
Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to