Getting the number of decimal places: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Removed comment and will comment in the talk page.)
m (→‎{{header|Python}}: The task refers to 'a given number' (and shows no quotes around the sample values))
Line 195: Line 195:


=={{header|Python}}==
=={{header|Python}}==
The task refers to 'a given number', but this appears to be a function over a string. )
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):
<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