Skip to content

Instantly share code, notes, and snippets.

@jackpordi
Created September 11, 2019 22:29
Show Gist options
  • Save jackpordi/adb4c47352a67d864fc5b2ad5fd5d6e2 to your computer and use it in GitHub Desktop.
Save jackpordi/adb4c47352a67d864fc5b2ad5fd5d6e2 to your computer and use it in GitHub Desktop.
current_count = 0
def add_counter(x):
global current_count
current_count = current_count + 1
return x + current_count
print(add_counter(5)) # Prints 6
print(add_counter(5)) # Prints 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment