def get_category_index_from_categories(categories, category):
    """
    Gets the index of a category from the categories dictionary. If the category
    doesn't exist, it creates a new entry for that category name and returns 
    the new index number.
    """
    if category not in categories:
        categories[category] = len(categories)
    return categories[category]