Format a float and put in a list

David Sulkin dsulkin at mqplp.com
Tue Feb 6 10:24:22 EST 2007


Hello all,

 

I found a workaround solution.  

 

I use the items in the list to be placed in a string, so I just
formatted the entire string to remove any single quotes.  Duh!

 

Thanks

 

________________________________

From: python-list-bounces+dsulkin=mqplp.com at python.org
[mailto:python-list-bounces+dsulkin=mqplp.com at python.org] On Behalf Of
David Sulkin
Sent: Tuesday, February 06, 2007 6:53 AM
To: python-list at python.org
Subject: Format a float and put in a list

 

Hello,

 

I have a float that I am trying to format to 2 decimal places, put the
formatted float in a list and then output this to a file.  My problem
is, once I format my float, my float has quotations around the float due
to my formatting.  I am doing the following:

 

(  "%.2f" % float( list[x] ) )

 

Is there a way I can format the float so when I see it in the file it
looks like [19.45, 20.52, 16.56] instead of ['19.45', '20.52', '16.56']?

 

Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070206/92e1b745/attachment.html>


More information about the Python-list mailing list