skip next item in list

Duncan Smith buzzard at urubu.freeserve.co.uk
Mon Jun 11 11:44:09 EDT 2007


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()

		
a
c
d
>>>

The binding of a name to it.next() is unnecessary.  It just prevents 'd'
being printed.

Duncan



More information about the Python-list mailing list