I am using Python3.7 and I am curious about the namespace of the dictionary. Here is My question.
Let's define a dict first:
r = {'a':[1,2,3], 'b':[4,5,6]}
then we define a function:
def fun1():
print(r['a'])
fun1()
Output: [1, 2, 3]
then We define another function:
def fun2():
r = {'a':[10,11,12],'c':[7,8,9]}
fun1()
fun2()
Output:[1, 2, 3]
Why isn't the output of fun2 [10,11,12], as r is redefined inside the function func2. But it seems to be pointing to what we defined at the beginning. Does scope not apply to dictionaries?