I have a variable n and I want to print n decimal places.
n
import math n = 5 print(f"{math.pi:.nf}")
ValueError: Format specifier missing precision
This doesn't work, but how might it be done?
Fields in format strings can be nested:
>>> print(f"{math.pi:.{n}f}") 3.14159
1.4m articles
1.4m replys
5 comments
56.9k users