List comprehension and string conversion with formatting

stephen_b redplusbluemakespurple at gmail.com
Tue Jun 9 11:38:34 EDT 2009


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]

StephenB



More information about the Python-list mailing list