The first code snippet prints [0, 3] out.
def func():
a = [0]
def swim():
a.append(3)
# a = [1]+a
return a
return swim()
print(func())
The second code snippet raises error "UnboundLocalError: local variable 'a' referenced before assignment"
def func():
a = [0]
def swim():
# a.append(3)
a = [1]+a
return a
return swim()
print(func())
Is a visible/accessible to function swim after all?