Converting a float to a formatted outside of print command

Iuri iurisilvio at gmail.com
Mon Nov 23 16:24:18 EST 2009


You forgot a % simbol in your string:

y = 0.5
x = '*%*.1f' % y

[]s
iurisilvio

On Mon, Nov 23, 2009 at 7:15 PM, stephen_b <redplusbluemakespurple at gmail.com
> wrote:

> I'd like to convert a list of floats to formatted strings. The
> following example raises a TypeError:
>
> y = 0.5
> x = '.1f' % y
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091123/07f96468/attachment.html>


More information about the Python-list mailing list