human
Complete the below
def coupon_codes_features(features, coupons_list, course_id):

    ''''Return list of Coupon Codes as dictionaries.
    coupon_codes_features
    would return [
    {\'course_id\': \'edX/Open_DemoX/edx_demo_course,, \'discount\': \'213\'  ..... }
    {\'course_id\': \'edX/Open_DemoX/edx_demo_course,, \'discount\': \'234\'  ..... }'
    '''
 ... What is a the Python program you requested?
assistant
#Here is the Python program you requested.
    def extract_coupon(coupon, features):
        '    convert    coupon_codes    to    dictionary\n                                :param    coupon_codes:\n                                :param    features:\n                                '
        coupon_features = [x for x in COUPON_FEATURES if (x in features)]
        coupon_dict = dict(((feature, getattr(coupon, feature)) for feature in coupon_features))
        coupon_redemptions = coupon.couponredemption_set.filter(order__status='purchased')
        coupon_dict['code_redeemed_count'] = coupon_redemptions.count()
        seats_purchased_using_coupon = 0
        total_discounted_amount = 0
        for coupon_redemption in coupon_redemptions:
            cart_items = coupon_redemption.order.orderitem_set.all().select_subclasses()
            found_items = []
            for item in cart_items:
                if getattr(item, 'course_id', None):
                    if (item.course_id == course_id):
                        found_items.append(item)
            for order_item in found_items:
                seats_purchased_using_coupon += order_item.qty
                discounted_amount_for_item = (float((order_item.list_price * order_item.qty)) * (float(coupon.percentage_discount) / 100))
                total_discounted_amount += discounted_amount_for_item
        coupon_dict['total_discounted_seats'] = seats_purchased_using_coupon
        coupon_dict['total_discounted_amount'] = total_discounted_amount
        coupon_dict['expiration_date'] = coupon.display_expiry_date
        coupon_dict['course_id'] = coupon_dict['course_id'].to_deprecated_string()
        return coupon_dict
    return [extract_coupon(coupon, features) for coupon in coupons_list]