I made the two functions below in Python 3. The first function test_list works fine with the list a without error. I can modify the list element in that function.
However, the second funciton test_int will pop an error local variable 'b' referenced before assignment. Why can't I do this to the variable b?
a=[1,2,3]
def test_list():
a[0]=2
return a
b = 2
def test_int():
b += 1
return b