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_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, [EMAIL PROTECTED] > ICQ: 6260644 -- Skype: a_engels > -- > http://mail.python.org/mailman/listinfo/python-list > another way:
def skip_after(l): i = iter(l) for x in i: yield x while x == 'a': x = i.next() depending on what to do in case of consecutive 'a's, change the 'while' for an 'if' list(skip_after('spam aand eggs')) ['s', 'p', 'a', ' ', 'a', 'd', ' ', 'e', 'g', 'g', 's'] -- http://mail.python.org/mailman/listinfo/python-list