Render_Hide

hello,i am new to blender coding

i want to make a script, to hide the render view of certain objects, every to 2 frames in time line
the script until now looks like this.

import bpy


scene = bpy.context.scene
 
i=0


while (1<=300):
    for ob in scene.objects:
        if ob.type == 'MESH' and ob.name.startswith("Cube"):
            ob.anim.keyframe_insert(hide_render = False)
            
i+=2            
print(i)