<s>[INST] Lexical Scope
=================

In functions, variables are visible only in their own scope or nested scopes, but values from outer scopes are accessible.


Variables bound to variables in an outer scope can modify values accessible from the inner function. However, it cannot store value of a new variable as it would become locally defined.

```python
# Outer function or scope
def outer_func(
```

The problem you've encountered with any attempt to assign a value in the inner function can be explained by the way Python treats variable assignments with respect to scope.


Nested Scopes

Consider the following example:

```python
def outer():
    x = 1
    
    def inner():
        print(x)  # Can we print x?[/INST]