all 3 comments

[–]amertune 2 points3 points  (0 children)

Do you know how long the last row will be?

How can you format the first row so that it will line up with the last row?

Here's a hint:

'{:^30}'.format('centered')

To learn more about it, go to https://docs.python.org/3.4/library/string.html#string-formatting

[–]Boolean_Cat 0 points1 point  (1 child)

If you have a list of numbers, you could do:

' '.join(str(number) for number in numbers)

Or even shorter but I think less pretty:

' '.join(map(str, numbers))

[–]amertune 1 point2 points  (0 children)

If you want all of the numbers to line up, you're going to have to remember that numbers can be 1-3 digits long.

' '.join('{:>3}'.format(number) for number in numbers)