String manipulations

Elliot Temple curi at curi.us
Sat May 28 18:16:20 EDT 2005


On May 28, 2005, at 2:52 PM, Lorn wrote:

> Yes, that would get rid of the decimals... but it wouldn't get rid of
> the extraneous precision. Unfortunately, the precision out to the ten
> thousandth is noise... I don't need to round it either as the numbers
> are artifacts of an integer to float conversion. Basically, I need to
> know how many decimal places there are and then make the necessary
> deletions before I can normalize by adding zeros, multiplying, etc.
>
> Thanks for your suggestion, though.

for s in numbers:
     decimal_index = s.find('.')
     decimal_places = len(s) - decimal_index - 1

Anything wrong with this?  (it will mess up if there isn't a decimal  
but you can fix that if you want)

-- Elliot Temple
http://www.curi.us/


---
[This E-mail scanned for viruses by Declude Virus]




More information about the Python-list mailing list