Sorry for the vague title, but I really have no idea what's going on here.
from functools import reduce
arr = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
def strxo(n):
if (n == -1):
return "X"
elif (n == 1):
return "O"
else:
return "_"
def prboard(board):
print(reduce(lambda x, y: x + "\n" + y, list(map(lambda l: reduce(lambda a, b: strxo(a) + strxo(b), l), board))))
prboard(arr)
Desired output:
___
___
___
Real output:
__
__
__
And when I change the final else
on strxo
to return str(n)
instead of return "_"
I get:
000
000
000
Which is what I would expect and the shape I want, but I want to replace those zeroes. What is causing this?