How can I add a collection using Python? I'm new to Blender. Tutorial information as recent as January this year appears to be out of date and I can't figure out how to create a new collection and add an object to it. The most recent relevant question I could find suggests this:
bus_collection = ops.collection.new(name=&quot;BusRoutes&quot;)
context.scene.collection.children.link(bus_collection)

and apparently at least needs to be changed to this:
bus_collection = ops.collection.create(name=&quot;BusRoutes&quot;)
etc.

which throws the error:
TypeError: CollectionChildren.link(): error with argument 1, &quot;child&quot; -  Function.child expected a Collection type, not set

The API entry for Collection operators is beyond sparse, and I'm not even sure what Add the object to an object collection that contains the active object even means.
May I ask someone to give me a minimal Blender 2.83 Python example of how to create a named collection and add an object to it? Many thanks.
BlendDataCollections.new(name)
Recommend use the python console to figure out:
&gt;&gt;&gt; D.collections.new(
new()
BlendDataCollections.new(name)
Add a new collection to the main database
...

&gt;&gt;&gt; my_coll = D.collections.new(&quot;MyCollection&quot;)
&gt;&gt;&gt; C.scene.collection.children.link(my_coll)

Demo on how to create a new collection and add the default cube using CollectionObjects.link(object):
import bpy

# New Collection
my_coll = bpy.data.collections.new(&quot;MyCollection&quot;)

# Add collection to scene collection
bpy.context.scene.collection.children.link(my_coll)

# Get cube object
obj = bpy.context.scene.objects.get(&quot;Cube&quot;)

if obj:
    # Link the cube 
    my_coll.objects.link(obj)