"JuHui" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> >>> a='String'
> >>> for x in a:
> ...     print x
> ...
> S
> t
> r
> i
> n
> g
> >>>
>
> can I get the index number  of a in the upon loop within for x in a
> loop?
>

Use enumerate.  See example below.

-- Paul

>>> a = "String"
>>> for x in a:
...   print x
...
S
t
r
i
n
g
>>> for x in enumerate(a):
...   print x
...
(0, 'S')
(1, 't')
(2, 'r')
(3, 'i')
(4, 'n')
(5, 'g')
>>>


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to