Dick Moores wrote: > def sigDigits(n): > """ > Strips any real decimal (as string) to just its significant digits, > then returns its length, the number of significant digits. > Examples: "-345" -> "345" -> 3; > "3.000" -> "3000" -> 4 > "0.0001234" -> "1234" -> 4; > "10.0001234" -> "100001234" -> 9 > "7.2345e+543" -> "72345" -> 5 > """ > s = str(n).lstrip("-+0") > s = s.lstrip(".") > s = s.lstrip("0") > s = s.lstrip(".")
Why the repeated strips? Couldn't this all just be done with lstrip('-+0.') ? How many significant digits are in 123000? Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor