Skip to content

Instantly share code, notes, and snippets.

@kadirpekel
Created July 25, 2012 13:21
Show Gist options
  • Save kadirpekel/3176161 to your computer and use it in GitHub Desktop.
Save kadirpekel/3176161 to your computer and use it in GitHub Desktop.
What is the output?
def create_counter():
i = 0
def increment():
i = i + 1
print(i)
return increment
count = create_counter()
count()
count()
count()
@bergerx
Copy link

bergerx commented Jul 25, 2012

@tayfun
Copy link

tayfun commented Aug 4, 2012

Here's py3k version: https://gist.github.com/3259093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment