What is mutability and why does it matter – Solution [2]

The function creating a blank table needs to be corrected, e.g., like this

def create_blank_table_corrected(rows, columns, fill_character="."):
    table = []
    for _ in range(n_rows):
        row = [fill_character] * n_columns
        table.append(row)
    return table

Let's run the code with the corrected function and see the result

table = create_blank_corrected(10, 10)
table[1][3] = "X"
table[4][4] = "O"
print_table(table)

Now, each row is a different is object and the result is correct.

. . . . . . . . . .
. . . X . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . O . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .