Elementary string-formatting
Odysseus
odysseus1479-at at yahoo-dot.ca
Sun Jan 13 05:13:47 EST 2008
In article <mailman.561.1200198783.896.python-list at python.org>,
Gary Herron <gherron at islandtraining.com> wrote:
> Odysseus wrote:
<snip>
> >
> > print '%2u %6u %4.2f' % \
> > (i, wordcounts[i], 100.0 * wordcounts[i] / wordcounts[0])
> >
> Using 4.2 is the problem. The first digit (your 4) give the total
> number of characters to use for the number.
Thanks; I was thinking the numbers referred to digits before and after
the decimal. The largest figures have five characters in all, so they
were 'overflowing'.
--
Odysseus
More information about the Python-list
mailing list