If I have for example x = 40 I want the following result:
40"
For x = 2.5 the result should be like…
2.5"
So I basically want to format to at most one decimal place. I currently use this:
"{0:0.1f}\"".format(x, 1)
But this displays always exactly one decimal place, which is not really what I want…
One option is something like
which will display
xas an integer if there’s no fractional part. There’s quite possibly a better way to go about this.