
Checkpoint
Checkpoint: The Case of the Twin Maps
Pip's map maker draws a sea and puts a square island on it. But instead of one island, a whole stripe of sand appears from top to bottom! And the island looks too thin.
The clue: [row] * 3 doesn't make three rows. It makes a list holding
the same row three times.
grid = [[0] * 3] * 3
grid[0][0] = 9
print(grid) # [[9, 0, 0], [9, 0, 0], [9, 0, 0]]
print(grid[0] is grid[1]) # True: twins!
A list comprehension runs [0] * 3 once per row, so each row is
new: [[0] * 3 for _ in range(3)].
Assignment
Fix the two bugs, one from each family:
make_grid(width, height, fill)must buildheightseparate rows, each holdingwidthcopies offill.mark_island(grid, x, y, size)must paint a fullsizebysizesquare of"sand", with its top-left corner at columnx, rowy.
The picture should show a 3 by 3 island in the sea.
Fix the two bugs, one from each family:
make_grid(width, height, fill)must buildheightseparate rows, each holdingwidthcopies offill.mark_island(grid, x, y, size)must paint a fullsizebysizesquare of"sand", with its top-left corner at columnx, rowy.
The picture should show a 3 by 3 island in the sea.
main.py Python sleeping
Press Run to try your code, then Check to test it.