我是python的新手,由于某种原因,global一词对我不起作用
def location():
global place
place = "Cape Town"
return
当我尝试打印位置时
print(place)
我遇到了这个错误
NameError Traceback (most recent call last)
<ipython-input-2-34a3a4594339> in <module>()
----> 1 print(place)
NameError: name 'place' is not defined