Anonymous user
Getting the number of decimal places: Difference between revisions
Getting the number of decimal places (view source)
Revision as of 09:34, 16 August 2020
, 3 years ago→{{header|Python}}: Explanation.
(→{{header|Python}}: Explanation.) |
|||
Line 194:
=={{header|Python}}==
Treated as a function over a string representation of a number to allow the capturing of significant trailing zeroes.
<lang python>In [6]: def dec(n):
...: return len(n.rsplit('.')[-1]) if '.' in n else 0
|