Created
January 18, 2020 21:25
-
-
Save edenau/d20af23b693aa0b61931823f734d75c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 1 # a variable | |
def increment(): | |
a += 1 | |
return a | |
def increment2(): | |
global a # can make changes to global variable "a" | |
a += 1 | |
return a | |
increment() # UnboundLocalError: local variable 'a' referenced before assignment | |
increment2() # returns 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment