Created
December 5, 2019 01:25
-
-
Save FerdinaKusumah/8cac72d37dafb6a8ee8e77b38a2e6406 to your computer and use it in GitHub Desktop.
Copy or Clone Variable
This file contains 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
from copy import deepcopy | |
"""Clone or copy object to new ones""" | |
a = [1, 2, 3, 4] | |
b = deepcopy(a) | |
"""Try to adding new value in list a""" | |
a.append(5) | |
"""Now print this value""" | |
print("Value in a is {}".format(a)) | |
# Value in a is [1, 2, 3, 4, 5] | |
print("Value in b is {}".format(b)) | |
# Value in b is [1, 2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment