CELLSIZE = 20 def draw_bucket(ctx, bucket): for row_index, row in enumerate(bucket): for cell_index, color in enumerate(row): ctx.fillStyle = color ctx.fillRect( cell_index * CELLSIZE, row_index * CELLSIZE, CELLSIZE, CELLSIZE )