Getting the number of decimal places: Difference between revisions
Getting the number of decimal places (view source)
Revision as of 09:27, 14 August 2020
, 3 years ago→{{header|Python}}
Line 188:
=={{header|Python}}==
( Though this fails with an error when the given number is math.e, math.pi, or math.tau, for example, all presumably 'numbers')
<lang python>In [6]: def dec(n):
...: return len(n.rsplit('.')[-1]) if '.' in n else 0
|