3 ms·
> Most programmers are surprised by the behavior of this snippet. Ok. I'll bite. I get UnboundLocalError: local variable 'a' referenced before assignment
by sandov 7y ago
> Most programmers are surprised by the behavior of this snippet.
Ok. I'll bite.
I get
UnboundLocalError: local variable 'a' referenced before assignment
shouldn't it print 0 twice, since a is considered a global variable at the time print(a) gets called?
EDIT: If I delete print(a), then it prints 0 twice. What the hell?