python TypeError: 'type' object is not subscriptable 如何解决? 5
代码如下:defNewBoard():board=[[0forxinrange(3)]foryinrange(3)]returnboarddefDisplayBoard(...
代码如下:
def NewBoard(): board = [[0 for x in range(3)] for y in range(3)] return boarddef DisplayBoard(board): for x in range[0, 3]: for y in range[0, 3]: print(board[x][y], sep=' |') print('\n')
DisplayBoard(NewBoard())
一运行就会出现题目中的报错怎么解决呀?我想输出这样的一个表格 展开
def NewBoard(): board = [[0 for x in range(3)] for y in range(3)] return boarddef DisplayBoard(board): for x in range[0, 3]: for y in range[0, 3]: print(board[x][y], sep=' |') print('\n')
DisplayBoard(NewBoard())
一运行就会出现题目中的报错怎么解决呀?我想输出这样的一个表格 展开
3个回答
展开全部
def NewBoard():
board = [[0 for x in range(3)] for y in range(3)]
return board
def DisplayBoard(board):
str1=''
for x in range(3):
for y in range(3):
str1+=str(board[x][y])
if y!=2:
str1+=' | '
print str1
str1=''
DisplayBoard(NewBoard())
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询