3

I dont know much about python and am learning.

I have a variable like this,

a = 23.34853234

I want to reduce the numbers after dot. Like, i have mentioned below

a = 23.35

Please help me. Thank you

user3136030
  • 384
  • 4
  • 9
  • 19

2 Answers2

5

you can use round

round(a, 2)

you can read more about it here here

amdorra
  • 1,536
  • 9
  • 18
0

You can do it this way:

a = float("{0:.2f}".format(a))
gthacoder
  • 2,213
  • 3
  • 15
  • 17