how can I fix the number of digits after the decimal place in python?

30 Views Asked by At

For Example this is my list

li = [4.0, 5.15445454, 1.1]

and I want to this

newli = [4.00000, 5.15445, 1.10000]
1

There are 1 best solutions below

0
Marko On

This answer explain more.

li = [4.0, 5.15445454, 1.1]
newli = ["%.5f" % a for a in li]