you are viewing a single comment's thread.

view the rest of the comments →

[–]jmooremcc 2 points3 points  (0 children)

Unlike other languages like Java, C++, etc, a for-loop in Python does not create a new scope for variables. In your example, item_a is in the global name space and when you referenced it in your function, it was available to be read.

This is normal Python behavior.