Skip to content

Instantly share code, notes, and snippets.

@strager
Created December 25, 2019 06:06
Show Gist options
  • Save strager/20454f445e5e4eee75006d0ac87c8ea7 to your computer and use it in GitHub Desktop.
Save strager/20454f445e5e4eee75006d0ac87c8ea7 to your computer and use it in GitHub Desktop.
x = 1
y = x
x += 2
print("numbers:", x, y)
# numbers: 3 1
x = ("hello",)
y = x
x += ("world",)
print("tuples:", x, y)
# tuples: ('hello', 'world') ('hello',)
x = ["hello"]
y = x
x += ["world"]
print("lists:", x, y)
# lists: ['hello', 'world'] ['hello', 'world']
# Program output:
# numbers: 3 1
# tuples: ('hello', 'world') ('hello',)
# lists: ['hello', 'world'] ['hello', 'world']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment