Getting the number of decimal places: Difference between revisions

(→‎{{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.
The task refers to 'a given number' (and shows no quotes around the sample values) but this appears to be a function over a string.
<lang python>In [6]: def dec(n):
...: return len(n.rsplit('.')[-1]) if '.' in n else 0
Anonymous user