Question: For quite a bit of time now I have been trying to figure out a way to loop through a list and remove the current item that I'm at. I can't seem to get this working as I would like it to. It loops just 1 time through, but I wanted it to loop 2 times. When I remove the removal line - it loops 2 times.

```
a = [0, 1]
for i in a:
    z = a
    print z.remove(i)

```

The output:

```
[1]

```

The output that I was expecting:

```
[1] 
[0]

```

Answer: 
You're changing the list while iterating over it -- `z = a` doesn't make a copy, it just points `z` at the same place `a` points.

Try 

```
for i in a[:]:          # slicing a list makes a copy
    print i             # remove doesn't return the item so print it here
    a.remove(i)         # remove the item from the original list

```

or

```
while a:                # while the list is not empty
    print a.pop(0)      # remove the first item from the list

```

If you don't need an explicit loop, you can remove items that match a condition with a list comprehension:

```
a = [i for i in a if i] # remove all items that evaluate to false
a = [i for i in a if condition(i)] # remove items where the condition is False

```
The problem is that you're modifying `a` with `remove` so the loop exits because the index is now past the end of it.