def avg_item_count_character(db):
    """Returns the average number of items per character from MongoDB
    database.

    Args:
        db (pymongo.database.Database): MongoDB database
    Returns:
        (float) Average number of items per character
    """
    agg_dict = [
        {
            "$lookup":
            {
                'from': 'armory.item',
                'localField': 'inventory',
                'foreignField': 'pk',
                'as': 'items_doc'
            }
        },
        {
            "$project":
            {
                "numberOfItems": {"$size": "$items_doc"}
            }
        },
        {
            "$group":
            {
                "_id": None,
                "avgItem": {"$avg": "$numberOfItems"}
            }
        }
    ]
    agg_res = db["charactercreator.character"].aggregate(agg_dict)
    return list(agg_res)[0]["avgItem"]