Name

nf()

Examples
a = 200 
b = 40 
c = 90
sa = nf(a, 10)
print(sa)  # Prints "0000000200"
sb = nf(b, 5)
print(sb)  # Prints "00040"
sc = nf(c, 3)
print(sc)  # Prints "090"
d = 200.94
e = 40.2
f = 9.012
sd = nf(d, 10, 4)
print(sd)  # Prints "0000000200.9400"
se = nf(e, 5, 3)
print(se)  # Prints "00040.200"
sf = nf(f, 3, 5)
print(sf)  # Prints "009.01200"
Description Utility function for formatting numbers into strings. There are two versions: one for formatting floats, and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers.

As shown in the above example, nf() is used to add zeros to the left and/or right of a number. This is typically for aligning a list of numbers. To remove digits from a floating-point number, use the int(), ceil(), floor(), or round() functions.
Syntax
nf(num, digits)
nf(num, left, right)
Parameters
numthe number(s) to format
digitsint: number of digits to pad with zero
leftint: number of digits to the left of the decimal point
rightint: number of digits to the right of the decimal point
Related nfs()
nfp()
nfc()

Updated on Mon Sep 21 15:53:25 2020.

If you see any errors or have comments, please let us know.