I just come across a confusion ,let's consider the below 2 codes

first code: 

```
def out():        #func1
    print i
i=5

Output:5

```

Second:

```
def inc():        #func2
        i=i+1
        print i
i=5

```

When execiting the above programs ,func1 doesn't give any error but func2 gives an error...

```
error: var i referenced before assignment

```

I am confused that i is a local variable or global.If it is local variable then how func1 is accessing it and if it's global then why func2 is unable to access it?