Look up the string's rfind method.
Chris
On Wed, Oct 13, 2010 at 4:28 PM, Pratik Khemka wrote:
> I want to search for a symbol in a string backwards..
> For eg:
>
> *line = "my/cat/dog/baby"*
> **
> *line.find('/')* *# but from the back...*
>
> The reason I want to do this is because I want t
On 10/13/2010 4:28 PM Pratik Khemka said...
line = "my/cat/dog/baby"
Introspection is your friend
>>> line = "my/cat/dog/baby"
>>> dir(line)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem_
_', '__getnewar
I want to search for a symbol in a string backwards..
For eg:
line = "my/cat/dog/baby"
line.find('/') # but from the back...
The reason I want to do this is because I want to print the last part of the
string after the '/' . And I do not know how long the string might be or how
many '/' i