 <p>"Global" means global to the module. Your <code>x</code> is not global; it is local to <code>banana</code>, but not to <code>apple</code>.</p> <p>In Python 3, you can use <code>nonlocal x</code> to make <code>x</code> assignable inside <code>apple</code>. In Python 2 there is no way to assign to <code>x</code> from inside <code>apple</code>. You must use a workaround such as making <code>x</code> a mutable object and mutating it (instead of assigning to it) in <code>apple</code>.</p>