Skip to content

Instantly share code, notes, and snippets.

@feliperuhland
Created October 5, 2015 13:34
Show Gist options
  • Save feliperuhland/a4aa3ef56c248a1007e3 to your computer and use it in GitHub Desktop.
Save feliperuhland/a4aa3ef56c248a1007e3 to your computer and use it in GitHub Desktop.
Python 2.7.10 (default, Sep 7 2015, 13:51:49)
[GCC 5.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 1
>>> def aa():
... print(a)
...
>>> aa()
1
>>> def aa():
... print(a)
... a = a + 1
...
>>> aa()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in aa
UnboundLocalError: local variable 'a' referenced before assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment