How to add a material to the active material slot with python I currently have

matName = "Black"

blendfile = addon_dir + "/assets/materials.blend"
selection = "\\Material\\"
material = matName

filepath = blendfile + selection + material
directory = blendfile + selection
filename = material
newMat = bpy.ops.wm.append(filepath=filepath, filename=filename, directory=directory)
mat = bpy.data.materials.get(material)
bpy.context.active_object.data.materials.append(mat)


this appends a material and adds it to the current object. The problem is that it adds a new material slot with the material. How can I make it add the appended material to the active slot?
The list of materials that shows in the material properties comes from

obj.material_slots


The index for the one that is selected in that list is

idx = obj.active_material_index


using that you assign a material to that slot with

obj.material_slots[idx].material = mat