How do I make a script for adding modifiers? I have made a script for adding VertexWeightMix modifers to a selected mesh. However, when I run the script, it adds tons of modifers, but only changes the first one it adds. How can I fix this? I don't want to apply them immediatly once a modifier is created.

for vertex_b in namelist:
    vertex_a = "bone_01D2"
    vertexA = bpy.context.object.vertex_groups.get(vertex_a)
    vertexB = bpy.context.object.vertex_groups.get(vertex_b)
    if vertexA is None:
        print("Vertex " + vertex_a + " Does not Exist!")
        continue
    if vertexB is None:
        print("Vertex " + vertex_b + " Does not Exist!")
        continue
    bpy.ops.object.modifier_add(type='VERTEX_WEIGHT_MIX')
    bpy.context.object.modifiers["VertexWeightMix"].vertex_group_a = vertex_a
    bpy.context.object.modifiers["VertexWeightMix"].vertex_group_b = vertex_b
    bpy.context.object.modifiers["VertexWeightMix"].mix_mode = 'ADD'
    bpy.context.object.modifiers["VertexWeightMix"].mix_set = 'B'


Edit: I figured out that if you declare a variable i = 0, then you can convert it to a string, append it to the name, then increase it. However, if I ran it again, it would not work.
I can just grab the length of the number of modifiers and then subtract it by one to get the index.

        bpy.context.object.modifiers[len(bpy.context.object.modifiers)-1].name = name
        bpy.context.object.modifiers[len(bpy.context.object.modifiers)-1].vertex_group_a = vertex_a
        bpy.context.object.modifiers[len(bpy.context.object.modifiers)-1].vertex_group_b = vertex_b
        bpy.context.object.modifiers[len(bpy.context.object.modifiers)-1].mix_mode = 'ADD'
        bpy.context.object.modifiers[len(bpy.context.object.modifiers)-1].mix_set = 'B'