I wrote a function that is supposed to insert a 2D list into a table.
This is the code:
seats_plan = [[True, True, True, True, True], [True, True, True, True, True], [True, True, True, True, True], [True, True, True, True, True], [True, True, True, True, True]]
def print_database(seats_plan):
for row in seats_plan:
row.insert(0, seats_plan.index(row))
seats_plan.insert(0, [' ', '0', '1', '2', '3', '4'])
for k in seats_plan:
for char in k:
if char is True:
print '.',
elif char is False:
print 'x',
else:
print char,
print
and the output is:
0 1 2 3 4
0 . . . . .
1 . . . . .
2 . . . . .
3 . . . . .
4 . . . . .
but it also changed seats_plan
, so if I call the function again it inserts the numbers again.
How can I make it insert it only once without changing the original seats_plan
?