set a specified vertex color to black via python how to set the vertex color in the center of the mesh to black and the rest of the vertices to red via python? a lot of the answers just tell me that i can color all the vertices in one face like that:

for poly in mesh.polygons:
for loop in poly.loop_indices:
    color_layer.data[loop].color = (0,0,0) 


but how can I get the specified vertex in the center and set it's color? Thank you very much



supplement(my script is as follows):

import bpy
import bmesh

#create a hexagon 
bpy.context.scene.cursor_location = 0.0, 0.0, 0.0
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
bpy.ops.mesh.primitive_circle_add(vertices=6,fill_type='NGON')
ob=bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.inset(thickness=0,depth=0)
bpy.ops.mesh.edge_collapse()

#I can select the center vertex in edit mode
bm = bmesh.from_edit_mesh(ob.data)
verts_center=[v for v in bm.verts if len(v.link_edges)==6]

vertexColors=ob.data.vertex_colors.new().data

#when it comes to object mode or vertex paint mode, how do I change the color of the vertex I selected?


as I know, in this example, the vertex I select will have six vertex color data, how do I get those six data and set the color?
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.