Skip to content

Instantly share code, notes, and snippets.

@treyhunner
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save treyhunner/c3ed941ead08da3b7d3d to your computer and use it in GitHub Desktop.

Select an option

Save treyhunner/c3ed941ead08da3b7d3d to your computer and use it in GitHub Desktop.
Explanation of how variable names work in Python
def change_variable(x):
x = 100
a = 3
print(a)
change_variable(a)
print(a)
b = [1, 2]
print(b)
change_variable(b)
print(b)
def change_list_item(x):
x.append(100)
c = [1, 2]
print(c)
change_list_item(c)
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment