index in for loops

Wojciech Muła wojciech_mula at poczta.null.onet.pl.invalid
Wed May 17 07:11:59 EDT 2006


manstey wrote:
> in for loops like the following:
>
> word='abcade'
>
> for letter in word:
>    print letter
>
>
> Is it possible to get the position of letter for any iteration through
> the loop?

for index, letter in enumerate(word):
	print index, letter



More information about the Python-list mailing list