Context for setting the end frame?

Hello,
I’m trying to write a script to render a frame for a certain number of positions. I have the number of positions as an int, and all I need to do is set the final frame to that number. I know from the API doc that the call is

bpy.ops.time.end_frame_set()

. I looked online and there was a guide saying to use

scene = bpy.context.scene

and then

context = scene.getRenderingContext()

but this second one fails because apparently scene doesn’t have that attribute. Just running the end_frame_set doesn’t work because the context is incorrect. I’m very new to Python in Blender and I’m still a bit confused as to what context is, exactly.
Thanks in advance!


context = bpy.context

scene = context.scene
f = 200
scene.frame_end = f

Works great, thank you very much!