string issue

Steven Bethard steven.bethard at gmail.com
Fri Feb 4 14:47:41 EST 2005


Steve Holden wrote:
> You are modifying the list as you iterate over it. Instead, iterate over 
> a copy by using:
> 
> for ip in ips[:]:
>   ...

Also worth noting, you can write this like:

     for ip in list(ips):
         ...

if you're afraid of smiley-faces [:] in your code. ;)

Steve



More information about the Python-list mailing list