Clear full rows
Pygame challenges · Blocks, step 3 of 3 · 30 XP
Full rows stay on the board and the stack only grows.
Your task
Write clear_rows(board). Keep the rows that still have an empty (None) square, in order. Then add one empty row on top for each row removed, so the board keeps its height. Return the new board and how many rows were cleared.
The game scores 100 for one row and 800 for four at once.
The function is at the top of the program, marked fix this. Press Run to play the game as it is, then Check when your function is ready.
What Check tests
| Call | Should give |
|---|---|
one full row at the bottomboard = [[None, None, None], ["r", None, "r"], ["r", "r", "r"]]clear_rows(board) | ([[None, None, None], [None, None, None], ["r", None, "r"]], 1) |
nothing to clearboard = [[None, None], ["r", None]]clear_rows(board) | ([[None, None], ["r", None]], 0) |
two full rowsboard = [["r", None], ["r", "r"], ["r", "r"]]clear_rows(board) | ([[None, None], [None, None], ["r", None]], 2) |
a full row in the middleboard = [[None, "r"], ["r", "r"], [None, "r"]]clear_rows(board) | ([[None, None], [None, "r"], [None, "r"]], 1) |