我试图在另一个函数中定义的函数中使用变量/列表,而不使其全局。
这是我的代码:
def hi(): hello = [1,2,3] print("hello") def bye(hello): print(hello) hi() bye(hello)
目前,我得到的错误是“ bye(hello)”中的“ hello”未定义。
我该如何解决?
python variables global function local
function ×1
global ×1
local ×1
python ×1
variables ×1