Created
March 29, 2014 19:18
-
-
Save petrblahos/9861165 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def make_text_table(row_count, column_width): | |
| """ | |
| Makes a textual table with the numbered rows and 2 columns. The first | |
| column is 5 characters wide, the 2nd and 3rd columns are column_width | |
| characters wide. | |
| Params: | |
| row_count The number of rows. The rows are then numbered | |
| 1 to row_count | |
| column_width The width of the second and third column. | |
| """ | |
| header = "+-----+" + "-" * column_width + "+" + "-" * column_width + "+" | |
| column_section = " " * column_width + "|" | |
| column_section = column_section * 2 | |
| print header | |
| for i in range(row_count): | |
| print ("|% 5d|" + column_section) % (i + 1, ) | |
| print header | |
| make_text_table(3, 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment