Question: do this code, do not use ord, continue , chegg, do not import, just fix my code, so it runs correctly def read _ file

do this code, do not use "ord", "continue" , "chegg", do not import, just fix my code, so it runs correctly
def read_file(file_name):
with open(file_name, 'r') as file:
width = int(file.readline())
height = int(file.readline())
grid =[]
for i in range(height):
row = file.readline().strip().split(',')
grid.append(row)
return grid
def make_empty_grid(grid):
empty_grid =[]
for row in grid:
empty_row =[]
for i in row:
empty_row.append('')
empty_grid.append(empty_row)
return empty_grid
def update_grid(grid):
directions =[(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]
for i in range(len(grid)):
for j in range(len(grid[0])):
if grid[i][j]=='0':
mine_count =0
for dx, dy in directions:
x, y = i + dx, j + dy
if 0<= x < len(grid) and 0<= y < len(grid[0]) and grid[x][y]=='X':
mine_count +=1
grid[i][j]= str(mine_count)
'''def dig(answer_grid, coordinate, user_view):
x = ord(coordinate[0])- ord('a')
y = int(coordinate[1])
user_view[x][y]= answer_grid[x][y]
def count_total_moves(user_view):
return sum(row.count('') for row in user_view)
def print_grid(grid):
width = len(grid[0])
height = len(grid)
for i, row in enumerate(reversed(grid)):
print(f"{height - i -1:2d}[{''.join(cell for cell in row)}]")
print(""+"".join(chr(ord('a')+ i) for i in range(width)))
def determine_game_status(grid, user_view):
for i, row in enumerate(grid):
for j, cell in enumerate(row):
if cell =='X' and user_view[i][j]!='':
return False
return True'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!