I thought list.extend and "+=" on list basically do the same thing - extends the list without creating new list.
I expect following code to print [42, 43, 44, 45, 46] but I'm getting UnboundLocalError: local variable 'x' referenced before assignment
Why I'm getting this error? Where is the difference?
def f():
    x.extend([43, 44])
def g():
    x += ([45, 46])
x = [42]
f()
g()
print x
I tried this in python2.7.3 and python3.4.0.
 
    