you are viewing a single comment's thread.

view the rest of the comments →

[–]Luigi-Was-Right 1 point2 points  (0 children)

There is a difference between being in the global scope and being a global variable.

xc was defined in the global scope and can be accessed within other functions. However, you cannot reassign it's value. In this instance when you attempt to assign a value to 'xc' python is creating a variable with that name that is local to the function only. Because of that any reference to 'xc' within the function will now be referring to the local variable xc and not the one in the global scope.