Re: skip next item in list

2007-06-11 Thread ahlongxp
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

Re: skip next item in list

2007-06-11 Thread Duncan Smith
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()

Re: skip next item in list

2007-06-11 Thread Rafael Darder Calvo
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

Re: skip next item in list

2007-06-11 Thread [EMAIL PROTECTED]
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

Re: skip next item in list

2007-06-11 Thread Diez B. Roggisch
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')

Re: skip next item in list

2007-06-11 Thread Andre Engels
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

skip next item in list

2007-06-11 Thread ahlongxp
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