String Formatting
Avell Diroll
avelldiroll at yahoo.fr
Thu Aug 10 08:56:01 EDT 2006
OriginalBrownster wrote:
> Hi there:
>
> I was wondering if its at all possible to search through a string for a
> specific character.
>
> I want to search through a string backwords and find the last
> period/comma, then take everything after that period/comma
>
> Example
>
> If i had a list: bread, butter, milk
>
> I want to just take that last entry of milk. However the need for it
> arises from something more complicated.
>
> Any help would be appreciated
>
Would that work for you ?
>>> a = 'bread, butter, milk'
>>> a
'bread, butter, milk'
>>> b = a.split(',')
>>> b
['bread', ' butter', ' milk']
>>> c = b[-1]
>>> c
' milk'
>>> d = c.strip()
>>> d
'milk'
HIH
Avell
More information about the Python-list
mailing list