I want to print my output as follows.Although it seems to be easy to be done in the first look, here are the problems. The number of columns can vary, it can be negative numbers, numbers with different digits etc.
So how can I do this perfectly so that the outer border remains intact irrespective of the varying factors inside.
I know I have to use string formatting in python, but not sure how to do it .
1. What logic should I use to print the header +---+
?
How to decide the length based on the no of elements inside?
2. How can I print the numbers with fixed width and alignment?
+---------------------------+
| 3 4 -4 -8 -10 -12 |
| 5 5 3 -3 -4 -44 |
| 34 -4 -34 -22 22 22 |
+---------------------------+
EDIT
I want to achieve this using string formatting and not with the help of a module.