String Manipulation
Cousin Stanley
CousinStanley at hotmail.com
Tue Jul 15 16:58:09 EDT 2003
| I need a piece of code that takes a string like this
| string1 = "aaa/bbb/ccc/dd" and extracts a string containting
| the character after the last "/"
|
| So for this example the result would be "dd"
| ...
lamar_air ...
Here is one way ...
>>> str_in = 'aaa/bbb/ccc/dd'
>>>
>>> list_in = str_in.split( '/' )
>>>
>>> last_element = list_in[ -1 ]
>>>
>>> print last_element
dd
>>>
--
Cousin Stanley
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list