skip next item in list

Duncan Smith buzzard at urubu.freeserve.co.uk
Mon Jun 11 17:44:09 CEST 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