Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

shorten all floats in a list

my_list = [1.000, 2.41, 2.5566778]
my_rounded_list = [ round(elem, 2) for elem in my_list ]
my_rounded_list == [1.00, 2.41, 2.56]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #shorten #floats #list
ADD COMMENT
Topic
Name
2+6 =