You can set the index of the list to `0`, iterate through all slots and override the context of [`material_slot_remove()`][1]. **Blender 3.2+** import bpy from bpy import context for obj in context.selected_editable_objects: obj.active_material_index = 0 for i in range(len(obj.material_slots)): with context.temp_override(object=obj): bpy.ops.object.material_slot_remove() **Blender 2.8+** import bpy for obj in bpy.context.selected_editable_objects: obj.active_material_index = 0 for i in range(len(obj.material_slots)): bpy.ops.object.material_slot_remove({'object': obj}) [1]: https://docs.blender.org/api/current/bpy.ops.object.html?highlight=material_slot_remove#bpy.ops.object.material_slot_remove