📜  UnboundLocalError:分配前引用的局部变量“msg” - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:11.479000             🧑  作者: Mango

代码示例1
Hey Mate, 

Issue is that you're calling variable r inside the def list_list. 
(reccomend to always keep your def on top or in another .py file to avoid this confusion)
happy coding.
Try:

def list_list(x, y):
    for i in x:

        y +=1
    print (y)

r = 0
list = ['apple','lime','orange']
list_list(list, r)