I have this code:
def table(h, w):table = [['.' for i in range(w)] for j in range(h)]return table
which returns this
[
['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']
]
How to make it return this?
[['.', '.', '.'],['.', '.', '.'],['.', '.', '.'],['.', '.', '.']
]
The (only) way to do it is actually to format the result (list type) to a string :
def table(h, w):table = [['.' for i in range(w)] for j in range(h)]return table
def format_table(table_):return "[\n" + ''.join(["\t" + str(line) + ",\n" for line in table_]) + "]"
print(format_table(table(3,3)))
Output :
[['.', '.', '.'],['.', '.', '.'],['.', '.', '.'],
]