I am new to Python. I am bit confused about how python function decides if a variable is referred or assigned. I think this determines whether the variable is global or local.
For example,
x = 1 #assignment
y = x + 1 #reference
x[0] = 1 #reference or assignment????
x += 1 #reference or assignment????
Is there any general rule that I don't know?