Answers for "shorten all floats in a list"

0

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]
Posted by: Guest on February-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language