Thats for this very humorous reply =D

On 10/26/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
Chris Hengge wrote:
> Here is my code:
> for unWantedItem in directoryList:
>             try:
>                 if "hex" in unWantedItem.lower():
>                     if not "bmc" in unWantedItem.lower():
>                        print unWantedItem + " removed!"
>                        directoryList.remove(unWantedItem)
>
> This only seems to loop through once, and removes 1 of 2 occurances
> from this list that should be captured. Should "for" keep the list
> going through each instance?
>
You're removing stuff from something you're iterating over!
*slaps your fingers with a ruler*
Make a copy of the list!
HTH,
-Luke


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to