Skip to content

Instantly share code, notes, and snippets.

@navenduagarwal
Created January 29, 2019 13:35
Show Gist options
  • Save navenduagarwal/4178029d5e4c5de28362a7012fba3715 to your computer and use it in GitHub Desktop.
Save navenduagarwal/4178029d5e4c5de28362a7012fba3715 to your computer and use it in GitHub Desktop.
Test for python mutability credits- sentdex
x = 1
def test():
x = 2
test()
print(x)
x = 1
def test():
global x
x = 2
test()
print(x)
x = [1]
def test():
x = [2]
test()
print(x)
x = [1]
def test():
global x
x = [2]
test()
print(x)
x = [1]
def test():
x[0] = 2
test()
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment