On Jun 9, 8:38 am, stephen_b <redplusbluemakespur...@gmail.com> wrote: > I'd like to convert a list of floats to a list of strings constrained > to one .1f format. These don't work. Is there a better way? > > [".1f" % i for i in l] > or > [(".1f" % i) for i in l]
You need a % in there, chief. [ "%.1f" % x for x in lst ] BTW, I took the liberty of making a few style choices, highly recommended: not to use "i" for floating points ("i" strongly suggests integer value to many programmers), and not using "l" (the letter ell) as a name, it can be hard to distinguish from a "1" (the number one). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list