Getting the number of decimal places: Difference between revisions

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
9,659

edits