How to add a triangulate modifier and apply it?
The list doesn’t contain the newly added triangulate modifier (if there is one). Also, it seems necessary to apply by name, not by type. The following works for me:

import bpy

obj = bpy.context.object

modif_types = [ modifier.type for modifier in obj.modifiers ]

if 'TRIANGULATE' not in modif_types:
    bpy.ops.object.modifier_add(type='TRIANGULATE')

modif_names = [ modifier.name for modifier in obj.modifiers ]

for modif in modif_names:
    bpy.ops.object.modifier_apply(apply_as='DATA', modifier=modif)