Hi All,
I am writing a program in which I take data for a table from the user, and then ask for the alignment for each column. Then I have to display it. Each column mush be separated by a tab and a space.
For example, let's say the user inputs that they want a 3 x 3 table to display "help I don't know how to do these tables."

 Help      I       dont
 know     how        to
 do      these   tables


Use the String.Formate method like
String.Format("{0,10:D}", 2)
This will format number 2 as a string of width 10 aligned to the right, use -10 to have it aligned on the left

There are two ways to do this, though one of them only works on 2.5 and later (it was developed for Python 3, then later backported to Python 2). In either approaches, you first need to use split() to divide the string into a list of individual words.

aprime = "help I don't know how to do these tables.".split(' ')

The first way to do this is to us string interpolation syntax, which provides a minimum field width argument to the formatting specifier.

print("%s%10s%10s\n%s%10s%10s\n%s%10s%10s" % tuple(aprime))

The second approach, which is a bit more flexible but is only supported under newer versions of the language, is to use the string method format(). This also has field width sub-field in its formatting specifiers, but can also define whether the word should be to the right, to the left, or to the center:


You first split the sentence into words, then print accordingly. I will leave dealing with punctuation to you. A simplified example:

test_input="help I don't know how to do these tables."
for outer in range(3):
    for inner in range(3):
        print test_list[ctr],
        ctr += 1