I want to format my float number with 2 digit after decimal.
>>> x =5.0
>>> y=float("{:0.2f}".format(x))
>>> y
5.0
i want my output in this format:
5.00
For newer version of python you can use:
x = 5.0
print(f' x: {x:.2f}')
out put will be:
x: 5.00
for more about this style see: f-string
Your answer was correct. you just misplaced the colon:
print "{:.2f}".format(5.0)
#output:
'5.00'
;)