1

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
  • 332
  • 3
  • 9
  • 19

2 Answers2

3

you can use round

round(a, 2)

you can read more about it here here

amdorra
  • 1,456
  • 9
  • 18
0

You can do it this way:

a = float("{0:.2f}".format(a))
gthacoder
  • 1,937
  • 2
  • 14
  • 16