Python: How to know how many objects are inside of the selection ? in this code 

import bpy 

def find_collection(context, item):
    collections = item.users_collection
    if len(collections) &gt; 0:
        return collections[0]
    return context.scene.collection

def make_collection(collection_name, parent_collection):
    if collection_name in bpy.data.collections:
        return bpy.data.collections[collection_name]
    else:
        new_collection = bpy.data.collections.new(collection_name)
        parent_collection.children.link(new_collection)
        return new_collection

for o in bpy.context.selected_objects:
    P = bpy.context.selected_objects[4]
    P_collection = find_collection(bpy.context, P)
    new_collection = make_collection("Quick Particle 01", P_collection)
    new_collection.objects.link(P)
    P_collection.objects.unlink(P)


im trying to move the whole selection to a new collection
i only have a single little problem, for it to work, i need the number at the end of this code 

    P = bpy.context.selected_objects[4]


to be the exact number of the number of objects inside of my selection -5..
so if i have 5 objects, i need [4]
if its more it dont work,if it less it doesnt work, and if its nothing witouth any braquet
like this 

    P = bpy.context.selected_objects


i get an error message 

so im searching to do something like that 

    P = bpy.context.selected_objects[***   bpy.context.numberofselected_objects"   ***]
In Python indexing works from the beginning AND from the end.
So if you need the second to last object in a list:

somelist = [ "a" , "b" ,"c" , "d" , "e" ]
print(somelist[-2])


would print

d