3
import math
def formating_pi(n):
a= "pi com {:c} casas decimais é {:.17}"
return a.format(n, math.pi)
formating_pi(5)
I’d like to not put the number 17 explicitly, but rather the result of the expression n + 1.
However, when I try to do this, the following error is raised:
ValueError: Format specifier missing precision.
Because the n or n + 1 are not seen as a numbers.
In this case n is 5 what is supposed to somehow result with output pi with 5 decimal places is 3.14159.
Thank you so much for the super quick reply Luiz.
– Uga Buga
@Ugabuga In my answer you have an option not to add 1 to
n:-)– hkotsubo