Source Code:
(back to article)
original_dict = {'key1': 'value1', 'key2': 'value2'} new_dict = original_dict.copy() # Add a new key-value pair to the new dictionary new_dict['key3'] = 'value3' print(original_dict) # {'key1': 'value1', 'key2': 'value2'} print(new_dict) # {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
Result:
Report an issue