News for hackers. Stuff that matters.
Re:Python overtakes Java to become second-most popular langu... by sandov on Sunday November 10, 2019 @03:47PM (#21500106)
> 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?

There are no comments on this comment yet.