Last active
October 30, 2017 09:47
-
-
Save ScottBurfieldMills/33cfa1c42124341c9fd7a590e6a6b53a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
list1 = [3, 2, 1] | |
tuple1 = (6, 4, 5) | |
print("BEFORE:", list1, tuple1) | |
fiddle2(list1, tuple1) | |
print(" AFTER:", list1, tuple1) | |
def fiddle2(some_list, a_tuple): | |
# Create a new list from the contents of the Tuple | |
# assignments to this variable are not reflected in the Tuple from main() | |
list2 = list(a_tuple) | |
list2[0] = 5 | |
some_list[0] = 5 | |
"""Change this variable to now point to the new list | |
as this variable no longer points to the list1 from main, | |
and it is not returned from the function, this final assignment | |
will not be reflected in the print() | |
""" | |
some_list = list2 | |
some_list[1] = list2[0] + 6 | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment