Python:点网格项目

问题描述 投票:0回答:1

我有一项工作,要求我们创建一个点网格以及一个光标,当给出命令时,该光标在网格上上下,左右,左右移动。到目前为止,我的问题是,当我使用show_grid()函数时,我不断收到错误代码(未定义名称“ show_grid”)。这是我到目前为止所拥有的。

x = y = 0
size = int(input('Enter the size of the board: '))
print(f'Current location: ({x},{y})')
show_grid(x,y)

while True:
    option = show_menu()
    if option == 0:
        print(f'Current location: ({x},{y})')
        break
    else:
        x, y = move(x, y, option)
    print(f'Current location: ({x},{y})')
    if 0 <= x < size and 0 <= y < size:
        show_grid(x,y)
    else:
        print('The new location is off the board.')
        break
print('Exit the program')
python grid dot
1个回答
0
投票

看来可能是导入问题,或者您需要为show_grid(x,y)定义方法。让我知道是否有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.