Shallow copies

Shallow copies of dictionaries can be made using dict.copy(), and of lists by assigning a slice of the entire list, for example, copied_list = original_list[:].

copied_list = original_list[:]

copied_dict = original_dict.copy()

Where original_obj is a dict or list:

import copy

copied_obj = copy.copy(original_obj)

Deep copies

Where original_obj is a dict or list:

import copy

copied_obj = copy.deepcopy(original_obj)