Question: how to fix that code to make look like the description import random from typing import List, Tuple, Optional def make_grid(w: int, h: int, player_coord:
how to fix that code to make look like the description
import random
from typing import List, Tuple, Optional
def make_grid(w: int, h: int, player_coord: Tuple[int, int], gold_coord: Tuple[int, int]) -> List[List[str]]: """ Given two integers width w and height h, create a list of lists to represent a grid of the given width and height.
The coordinates for the player and the gold is also given as two two-element tuples. For each tuple, the first element has the x-coordinate and the second element has the y-coordinate. The player and the gold should be included in the grid in the positions specified by these tuples.
The player is represented with the string '(x)' The gold is represented with the string '(o)' All other spaces are represented with the string '(_)'
Return this list.
>>> >>> make_grid(2, 3, (0, 0), (1, 2)) [['(x)', '(_)'], ['(_)','(_)'], ['(_)', '(o)']] """ grid = [] for i in range(h): inside = [] for j in range (w): inside.append("(_)") grid.append(inside)
x, y = player_coord grid[y][x] = '(x)' x, y = gold_coord grid[y][x] = '(o)' return grid
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
