set a specified vertex color to black via python
Look at the loop vert.
Using a method similar to Applying per-vertex colors to new Bmesh
import bpy
import bmesh
from random import uniform
context = bpy.context
mesh = context.object.data
bm = bmesh.new()
bm.from_mesh(mesh)

color_layer = bm.loops.layers.color.new(&quot;color&quot;)
red = (1, 0, 0, 1)
black = (0, 0, 0, 1)
for face in bm.faces:
    for loop in face.loops:
        print(&quot;Vert:&quot;, loop.vert.index)
        loop[color_layer] = black if len(loop.vert.link_edges) == 6 else red

bm.to_mesh(mesh) 


Result of running on a pre-made mesh.