| 1 | initial version |
You may use a while loop instead. It is never sane to modify the list you iterate on inside a for loop.
i = 0
while i < len(L):
x = L[i]
for l in srange(N):
if not (l in L) and M[x,l] != 0:
L = np.append(L,l)
Comment: the test "l in L" might be expensive (if the answer is False then you have to look through the whole list).
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.