Getting the number of decimal places: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Explanation.)
m (→‎{{header|Python}}: ( help with spelling ))
Line 194: Line 194:


=={{header|Python}}==
=={{header|Python}}==
Treated as a function over a string representation of a number to allow the capturing of significant trailing zeroes.
Treated as a function over a string representation of a number to allow the capturing of significant trailing zeros.
<lang python>In [6]: def dec(n):
<lang python>In [6]: def dec(n):
...: return len(n.rsplit('.')[-1]) if '.' in n else 0
...: return len(n.rsplit('.')[-1]) if '.' in n else 0