skip next item in list

Andre Engels andreengels at gmail.com
Mon Jun 11 10:53:39 EDT 2007


2007/6/11, ahlongxp <ahlongxp at gmail.com>:
> list=('a','d','c','d')
> for a in list:
>     if a=='a' :
>         #skip the letter affer 'a'
>
> what am I supposed to do?

There might be better ways to do it, but I would do:

flag_last_a = False
for a in list:
   if flag_last_a:
       flag_last_a = False
       continue
   if a=='a':
       flag_last_a = True
   # Whatever is done when you don't skip

-- 
Andre Engels, andreengels at gmail.com
ICQ: 6260644  --  Skype: a_engels



More information about the Python-list mailing list