Indexing strings

Patrick Useldinger pu.news.001 at gmail.com
Sat Mar 5 00:01:48 CET 2005


Fred wrote:

> I am searching for a possibility, to find out, what the index for a
> certain lettyer in a string is.
> My example:
> 
> for x in text:
>    if x == ' ':
>       list = text[:      # There I need the index of the space the
> program found during the loop...
> 
> Is there and possibility to find the index of the space???
> Thanks for any help!
> Fred

Use the index method, e.g.: text.index(' ').
What exactly do you want to do?

-pu



More information about the Python-list mailing list