Converting a float to a formatted outside of print command

Dan Bishop danb_83 at yahoo.com
Mon Nov 23 16:17:42 EST 2009


On Nov 23, 3:15 pm, stephen_b <redplusbluemakespur... 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

You meant:

x = '%.1f' % y



More information about the Python-list mailing list