I'm trying to write a program that displays the board as a list of list (the way as it is) with '_' (hidden squares), '.' (bombs), ' ' (empty squares), or '1', '2', etc.
game = {'dimensions': [2, 4],
'board': [['.', 3, 1, 0],
['.', '.', 1, 0]],
'mask': [[False, True, False, False],
[False, False, False, False]],
'state': 'ongoing'}
expected return
[['.', '3', '1', ' '],
['.', '.', '1', ' ']]
My attempt to change it in place:
def transform(game):
for outer in game['board']:
for inner in outer:
if inner ==0:
inner =' '
else:
inner = "\'"+str(inner)+"\'"
print("inner", inner)
print(type(inner))
return game['board']
I got print of each inner to be string in the desired format, but the final return didn't get changed at all?? :
...
inner '3'
<class 'str'>
inner '1'
<class 'str'>
inner ...
[['.', 3, 1, 0],['.', '.', 1, 0]]