12/15 purify


#1

why this code doesn’t work…?


#2

.remove() is a difficult approach, lists can’t have empty indexes, so when you do:

x = [4, 5, 5, 4]
x.remove(5)
print x

you see that everything to the right of the removed item shifts one index to the left. Combined with the loop you use, this causes a successive odd number to be skipped (given the loop moves to the next index after the index shift)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.