问题描述
test_board = ['1','2','3','4','5','6','7','8','9']
display_board(test_board)
def display_board(board):
print(| |)
print(+ board [6] +'|'+ board [7] +'|'+ board [8] +)
print('------------')
print(||)
print(+ board [ 3] +'|'+ board [4] +'|'+ board [5] +)
print('------- -----')
打印(| |)
print(+ board [0] +'|'+ board [ 1] +'|'+板[2] +)
结束
我有什么试过:
我试图将列表作为参数传递给函数display_board。
test_board = ['1','2','3','4','5','6','7','8','9']
display_board(test_board)
def display_board(board):
print(" | | ")
print(" "+board[6]+" "'|'" "+board[7]+" "'|'" "+board[8]+" ")
print('------------')
print(" | | ")
print(" "+board[3]+" "'|'" "+board[4]+" "'|'" "+board[5]+" ")
print('------------')
print(" | | ")
print(" "+board[0]+" "'|'" "+board[1]+" "'|'" "+board[2]+" ")
end
What I have tried:
I am trying to pass a list as an argument to a function display_board.
推荐答案
def display_board(board):
print(" | | ")
print(" "+board[6]+" "'|'" "+board[7]+" "'|'" "+board[8]+" ")
print('------------')
print(" | | ")
print(" "+board[3]+" "'|'" "+board[4]+" "'|'" "+board[5]+" ")
print('------------')
print(" | | ")
print(" "+board[0]+" "'|'" "+board[1]+" "'|'" "+board[2]+" ")
test_board = ['1','2','3','4','5','6','7','8','9']
display_board(test_board)
这篇关于运行以下代码时,我收到以下错误 - “list”对象不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!