def main(client, key_id):
  # Initialize appropriate service.
  custom_targeting_service = client.GetService(
      'CustomTargetingService', version='v201508')

  filter_values = [{
      'key': 'keyId',
      'value': {
          'xsi_type': 'NumberValue',
          'value': key_id
      }
  }]
  query = 'WHERE customTargetingKeyId = :keyId'
  statement = dfp.FilterStatement(query, filter_values)

  deleted_custom_targeting_values = 0

  # Get custom targeting values.
  while True:
    response = custom_targeting_service.getCustomTargetingValuesByStatement(
        statement.ToStatement())
    if response in 'results':
      value_ids = [value['id'] for value in response['results']]
      action = {'xsi_type': 'DeleteCustomTargetingValues'}
      value_query = ('WHERE customTargetingKeyId = :keyId '
                     'AND id IN (%s)' % ', '.join(value_ids))
      value_statement = dfp.FilterStatement(value_query, filter_values)

      # Delete custom targeting values.
      result = custom_targeting_service.performCustomTargetingValueAction(
          action, value_statement.ToStatement())
      if result and int(result['numChanges']) > 0:
        deleted_custom_targeting_values += int(result['numChanges'])
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

  if deleted_custom_targeting_values > 0:
    print ('Number of custom targeting values deleted: %s'
           % deleted_custom_targeting_values)
  else:
    print 'No custom targeting values were deleted.'
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201508/custom_targeting_service/delete_custom_targeting_values.py/main/swapped operands of `in`