Inserting '-' character in front of all numbers in a string
John Nagle
nagle at animats.com
Fri Mar 30 17:58:46 EDT 2007
Paul McGuire wrote:
> On Mar 30, 2:09 pm, Michael Bentley <mich... at jedimindworks.com> wrote:
>
>>On Mar 30, 2007, at 10:38 AM, kevinliu23 wrote:
>>
>>
>>
>>
>>
>>
>>>I want to be able to insert a '-' character in front of all numeric
>>>values in a string. I want to insert the '-' character to use in
>>>conjunction with the getopt.getopt() function.
' '.join(map(lambda x: '-' + x, s.split()))
assuming that you just want to put a "-" in front of each field,
regardless of its content.
John Nagle
More information about the Python-list
mailing list