首页 > 解决方案 > 为什么我的列表取另一个列表的值?

问题描述

这是我的代码:

def countCase(y, x, brd):
if x < len(brd[1])-1 and y < len(brd)-1:
    if brd[y][x] == '-':
        count = 1
        brd[y] = brd[y][:x]+'x'+brd[y][x+1:]
        count += countCase(y+1, x, brd)
        count += countCase(y-1, x, brd)
        count += countCase(y, x+1, brd)
        count += countCase(y, x-1, brd)
        return count
return 0

dirval[0] = countCase(pos['y']-1, pos['x'], board)
dirval[1] = countCase(pos['y']+1, pos['x'], board)
dirval[2] = countCase(pos['y'], pos['x']-1, board)
dirval[3] = countCase(pos['y'], pos['x']+1, board)

我的问题是:

谢谢你的帮助。

标签: pythonpython-3.xlistfunction

解决方案


推荐阅读