Script - remove multiple material slots - Blender 2.8
This script will delete the n_to_remove last material slots of your active object in reversed order (from the last material slot down).

import bpy
o  = bpy.context.object
ms = o.material_slots

n_to_remove = 3 # Change this number to decide how many material slots to remove
for i in range( len(ms) - 1, len(ms) - n_to_remove - 1, -1):
    o.active_material_index = i
    bpy.ops.object.material_slot_remove()