formatting strings to have the same width

spohle spohle at gmail.com
Sat Mar 17 19:07:44 EDT 2007


hi,

i got random strings and wanna attach a " |  " at the end. now if i
print them i want the | to always be underneath each other. example
code:

foo = ["aaa", "1232"]
for each in foo:

print foo[0].center(10, " ") + " | "
foo2 = "1232"
print foo2.center(10, " ") + " | "

even though i define a constant width on the strings the | don't show
up underneath each other.
any ideas ?




More information about the Python-list mailing list