Case of enclosures

how in the case of enclosures inner function was able to access value of variable from outer function?
when we were just printing value?

def outer():
    x="local"
    def inner():
        print(x)
    inner()
outer()

Ide Link

but this accessing fails when we are trying to change the value?

Local -> Enclosed -> Global

where the arrows should denote the direction of the namespace-hierarchy search order.

Local can be inside a function or class method
Enclosed can be its enclosing function, e.g., if a function is wrapped inside another function.
Global refers to the uppermost level of the executing script itself

So, if a particular name cannot be found in the local namespaces, the namespaces of the enclosed scope are being searched next. If the search in the enclosed scope is unsuccessful, too, Python moves on to the global namespace

but when we try to change the outer variable from inner function it creates a local copy of that variable