Collection name for selected objects

Hello.
Can I get the name of the collection for selected objects or object to get in the console for example?


I can get a name for example through ()
But this does not attach to the selected object.
Like here.
The object is located in another collection that is originally allocated and it is considered active it and withdraws it.

The following should be functional in blender 4.1

Keep in mind a single object can potentially be linked to multiple collections.

import bpy

sel_objs = bpy.context.selected_objects

def op_names(objs):
    for obj in objs:
        print(f"obj: {obj.name}", end='')
        for coll in obj.users_collection:
            print(f"\t coll: {coll.name}", end='')
        print()

op_names(sel_objs)