[Numpy-discussion] String manipulation

Francesc Alted faltet@pytables....
Thu Apr 23 02:35:23 CDT 2009

A Thursday 23 April 2009, Nils Wagner escrigué:
> Hi all,
> How can I obtain the position of the minus sign within the
> following string ?
> >>> liste[1]
> '1.5-te'

That's easy by using basic weaponery in Python:

In [8]: liste[1].find('-')
Out[8]: 3

In [9]: liste[1][3]
Out[9]: '-'

Francesc Alted

"One would expect people to feel threatened by the 'giant
brains or machines that think'.  In fact, the frightening
computer becomes less frightening if it is used only to
simulate a familiar noncomputer."

-- Edsger W. Dykstra
   "On the cruelty of really teaching computer science"

More information about the Numpy-discussion mailing list