Thanks to all of you.
I think the next() trick is the one I'm looking for.
--
ahlongxp
Software College,Northeastern University,China
[EMAIL PROTECTED]
http://www.herofit.cn
--
http://mail.python.org/mailman/listinfo/python-list
ahlongxp wrote:
> list=('a','d','c','d')
> for a in list:
> if a=='a' :
> #skip the letter affer 'a'
>
> what am I supposed to do?
>
Maybe,
>>> it = iter(['a','d','c','d'])
>>> for item in it:
print item
if item == 'a':
x = it.next()
On 6/11/07, Andre Engels <[EMAIL PROTECTED]> wrote:
> 2007/6/11, ahlongxp <[EMAIL PROTECTED]>:
> > 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
On Jun 11, 8:49 am, ahlongxp <[EMAIL PROTECTED]> wrote:
> list=('a','d','c','d')
> for a in list:
> if a=='a' :
> #skip the letter affer 'a'
>
> what am I supposed to do?
You could do this with itertools.ifilter and an predicate (pred) for a
more OO solution. I've created 2 lists, the
ahlongxp wrote:
> list=('a','d','c','d')
> for a in list:
> if a=='a' :
> #skip the letter affer 'a'
>
> what am I supposed to do?
First - don't use list as name, as it is a builtins-name and shadowing is
likely to produce errors at some point.
list_iterator = iter(('a','d','c','d')
2007/6/11, ahlongxp <[EMAIL PROTECTED]>:
> 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 = F
list=('a','d','c','d')
for a in list:
if a=='a' :
#skip the letter affer 'a'
what am I supposed to do?
--
http://mail.python.org/mailman/listinfo/python-list