A simple function but doesn't work!

Hi,

I use a simple function to delete item from a canvas:

for object in listObjects:
    canvas.RemoveObject(object)
    listObject.remove(object)

when the loop is finished there is still an element and I don't understand why!??? The same problem appears with this example :

a = ['1','2','3','4','5']

for element in a:
    a.remove(element)

print a give :
['5']

but if I use this algo there is no problems!

a = ['1','2','3','4','5']

for element in a:
    print element # in my case, remove an object from somewhere

if len(a) > 0:
    a = []

Personnally i prefer my first algo! But I don't understand why he doesn't work? Could someone help me to understand what's happen??