def total_cost(single_plan):
    """Returns total cost of a single plan

    Parameter
    single_plan: single plan from database

    Returns: total cost of a single plan"""
    costs = single_plan.cost_set.all()
    if costs:
        total_cost = 0
        for cost in costs:
            total_cost += cost.cost

        return total_cost
    else:
        return 0