I need to format the number of decimal places that a variable displays in an f-string using a variable for the number of places.
n = 5
value = 0.345
print(f'{value:.4f}')
Instead of value.4f
, I need value.nf
where n
is the number of decimal places to which the variable should be rounded.