Reputation: 333
I am creating a program that has the user enter a list and then generates a table from that list. The elements in that list (for the new_table
function) will become the the label for the columns.
from sys import stdout
def new_table(columns):
for i in columns:
length = len(i)
stdout.write('-' * (length + 8))
print('\r')
for x in columns:
stdout.write('| ' + i + ' |')
new_table(['Animal', 'Danger'])
However, when I run the program, in stead of displaying both elements of the list as the column titles/labels it displays only the second for both titles (the second element replaces the first):
----------------------------
| Danger || Danger |
I would like it to display like this:
----------------------------
| Animal || Danger |
Thanks for the help and suggestions.
Upvotes: 0
Views: 86