how to explain such codes, python's bug or mine?

ajikoe at gmail.com ajikoe at gmail.com
Wed Apr 13 06:08:33 EDT 2005


Hi,

it is not python bug.
You refer the list j and remove the element in the same time, that is
the problem. Python dinamicaly goes to the next element with the same
index but apply it in the new list.

use this code instead:
  j = range(20)
  print j
  L = [x for x in j if x > 10]
  print L

Sincerely Yours,
Pujo




More information about the Python-list mailing list