Is this piece of code potentially dangerous? Depends. Reducing the size of a sequence while iterating over it would give unexpected behavior.
Consider this Example
listA = [1,2,3,4]
>>> for a in listA:
listA.remove(a)
print a
Because, on removing the items, all the items beyond it, are pushed towards the left, the item that you are supposing to iterate would automatically move to the next element
First Iteration:
listA = [1,2,3,4]
^
|
_____________|
listA.remove(a)
listA = [2,3,4]
^
|
_____________|
print a
(outputs) 1
Second Iteration:
listA = [2,3,4]
^
|
_______________|
listA.remove(a)
listA = [2,4]
^
|
_______________|
print a
(outputs) 3
Third Iteration:
listA = [2,4]
^
|
_________________|
(Exits the Loop)