【发布时间】:2012-11-10 14:20:09
【问题描述】:
def make_str_from_row(board, row_index):
''' (list of list of str, int) -> str
Return the characters from the row of the board with index row_index
as a single string.
>>> make_str_from_row([['A', 'N', 'T', 'T'], ['X', 'S', 'O', 'B']], 0)
'ANTT'
'''
for i in range(len(board)):
i = row_index
print(board[i])
这打印['A', 'N', 'T', 'T']
我如何像这样打印'ANTT'?
【问题讨论】:
-
你的缩进是错误的。使用四个空格。
-
i = row_index这行很奇怪。你的意思是if i == row_index:? -
@0605002:那也很奇怪
-
@0605002:除了一个值之外什么都不做,为什么还要遍历
i的所有值? -
@Eric 哈哈,是的!我有点晚了。
标签: python python-3.x