Source Code:
(back to article)
import copy original_list = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # Create a deep copy of the list copied_list = copy.deepcopy(original_list) # Modify the first sublist of the copied list copied_list[0][1] = 99 # Print the original list print(original_list) # Output: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Result:
Report an issue