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
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
 
    
    You can do it by
In [11]: x = 5
In [12]: print("%.2f" % x)
5.00
In [13]:
 
    
    Your answer was correct. you just misplaced the colon:
print "{:.2f}".format(5.0)
 #output:
'5.00'
;)
