I want to make a capsule by changing the distance between the two halves of the sphere to a certain depth
import bpy
import bmesh
bm = bmesh.new()
bmesh.ops.create_uvsphere(bm, u_segments=8, v_segments=9, radius=2)
name = 'Capsule'
mesh = bpy.data.meshes.new(name)
bm.to_mesh(mesh)
mesh.update()
bm.free()
object = bpy.data.objects.new(name, mesh)
bpy.context.scene.collection.objects.link(object)