Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

aligning print statements in python

Name: Anonymous 2011-09-13 17:53

I'm trying to format my output so that everything lines up properly along the left side. I'm also rounding everything to 2 decimal places. The decimals are fine, however there isn't a proper number of spaces between Length and then the value.


print('Length: %10.2f' % length)
print('Width: %10.2f' % width)

What I want:
Length:      20.22
Width:       40.23

I realize this may seem like a very elementary question, but I've given myself a headache over the last hour trying to do this myself.

Name: Anonymous 2011-09-13 17:58

\t

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List