E
Enrique
a=[1,2,3,4,5].... a.remove(b)
....
....
Enrique said:... a.remove(b)a=[1,2,3,4,5]
for b in a:
...a [2, 4]
Very interesting result but reasonable. If the underlying interpreter usesEnrique said:... a.remove(b)a=[1,2,3,4,5]
for b in a:
...a [2, 4]
Smille Purusa said:Very interesting result but reasonable. If the underlying interpreter usesEnrique said:
a reference or pointer for the job like this:
# psudo codes for python
for(ptr = a.first(); ptr.is_valid(); ++ptr)
{
update('b', value(ptr))
call_method('a', 'remove', get_alue('b'))
}
ptr may be just an index. So at the first iteration, the first element, '1',
is removed from a. The next time ptr=1, but a has been changed to [2,3,4,5],
so '3' is removed, and so on,
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.