I have a variable n
and I want to print n decimal places.
import math
n = 5
print(f"{math.pi:.nf}")
ValueError: Format specifier missing precision
This doesn't work, but how might it be done?
question from:https://stackoverflow.com/questions/65940742/how-to-format-to-n-decimal-places-in-python