Source Code:
(back to article)
original_dict = {'a': [1, 2, 3], 'b': 4} new_dict = original_dict.copy() # Modifying original dict original_dict['a'].append(4) # Modifying new dict new_dict['b'] = 6 print(original_dict) # Output: {'a': [1, 2, 3, 4], 'b': 4} print(new_dict) # Output: {'a': [1, 2, 3, 4], 'b': 6}
Result:
Report an issue