Index counting from the last char
Duncan Booth
duncan.booth at invalid.invalid
Mon May 22 03:41:39 EDT 2006
gisleyt wrote:
> I'd like to use the index-function to retrieve a certain char in a
> string, but i need it to start counting from the last char.
>
> E.g. in the string.
>
> Foo-bar, foo foo-bar
>
> I want the latter hyphen to be returned when i do a index for '-'. Is
> there any built in function for this, I don't want to reverse every
> string just to do this.
>
str.rindex
More information about the Python-list
mailing list