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