-2

I have this:

a = "2.10"
print float(a)

Where output is:

2.1

But I need output as it is.

2.10
DjaouadNM
  • 22,013
  • 4
  • 33
  • 55
Suparno
  • 111
  • 1
  • 6

1 Answers1

4

You can use the .2f format for this:

a = "2.10"
print "%.2f" % float(a)

Output:

2.10
DjaouadNM
  • 22,013
  • 4
  • 33
  • 55