def BuildAdGroupCriterionOperations(adgroup_operations, number_of_keywords=1):
  """Builds the operations adding a Keyword Criterion to each AdGroup.

  Args:
    adgroup_operations: a list containing the operations that will add AdGroups.
    number_of_keywords: an int defining the number of Keywords to be created.

  Returns:
    a list containing the operations that will create a new Keyword Criterion
    associated with each provided AdGroup.
  """
  criterion_operations = [
      {
          # The xsi_type of the operation can usually be guessed by the API
          # because a given service only handles one type of operation.
          # However, batch jobs process operations of different types, so
          # the xsi_type must always be explicitly defined for these
          # operations.
          'xsi_type': 'AdGroupCriterionOperation',
          'operand': {
              'xsi_type': 'BiddableAdGroupCriterion',
              'adGroupId': adgroup_operation['operand']['id'],
              'criterion': {
                  'xsi_type': 'Keyword',
                  # Make 50% of keywords invalid to demonstrate error handling.
                  'text': 'mars%s%s' % (i, '!!!' if i % 2 == 0 else ''),
                  'matchType': 'BROAD'
              }
          },
          'operator': 'ADD'
      }
      for adgroup_operation in adgroup_operations
      for i in range(number_of_keywords)]

  return criterion_operations
def BuildAdGroupCriterionOperations ( adgroup_operations , number_of_keywords = 1 ) : criterion_operations = [ { 'xsi_type' : 'AdGroupCriterionOperation' , 'operand' : { 'xsi_type' : 'BiddableAdGroupCriterion' , 'adGroupId' : adgroup_operation [ 'operand' ] [ 'id' ] , 'criterion' : { 'xsi_type' : 'Keyword' , 'text' : 'mars%s%s' % ( i , '!!!' if i % 2 == 0 else '' ) , 'matchType' : 'BROAD' } } , 'operator' : 'ADD' } for adgroup_operation in adgroup_operations for i in range ( number_of_keywords ) ] return criterion_operations
Builds the operations adding a Keyword Criterion to each AdGroup.

  Args:
    adgroup_operations: a list containing the operations that will add AdGroups.
    number_of_keywords: an int defining the number of Keywords to be created.

  Returns:
    a list containing the operations that will create a new Keyword Criterion
    associated with each provided AdGroup.