Format all elements of a list
- by Curious2learn
I want to print a list of numbers, but I want to format each member of the list before it is printed.
For example,
theList=[1.343465432, 7.423334343, 6.967997797, 4.5522577]
I want the following output printed given the above list as an input:
[1.34, 7.42, 6.97, 4.55]
For any one member of the list, I know I can format it by using,
print "%.2f" % member
Is there a command/function that can do this for the whole list. I can write one, but was wondering if one already exists.
Thanks.