# replace_elements¶

`sequencetools.``replace_elements`(sequence, indices, new_material)

Replaces sequence elements.

Example 1. Replaces elements at indices 0, 2, 4, 6 with `'A'`, `'B'`, `'C'`, `'D'`, respectively:

```>>> sequencetools.replace_elements(
...     list(range(16)),
...     ([0], 2),
...     (['A', 'B', 'C', 'D'], None),
...     )
['A', 1, 'B', 3, 'C', 5, 'D', 7, 8, 9, 10, 11, 12, 13, 14, 15]
```

Example 2. Replaces elements at indices 0, 1, 8, 13 with `'A'`, `'B'`, `'C'`, `'D'`, respectively:

```>>> sequencetools.replace_elements(
...     list(range(16)),
...     ([0, 1, 8, 13], None),
...     (['A', 'B', 'C', 'D'], None),
...     )
['A', 'B', 2, 3, 4, 5, 6, 7, 'C', 9, 10, 11, 12, 'D', 14, 15]
```

Example 3. Replaces every element at an even index with `'*'`:

```>>> sequencetools.replace_elements(
...     list(range(16)),
...     ([0], 2),
...     (['*'], 1),
...     )
['*', 1, '*', 3, '*', 5, '*', 7, '*', 9, '*', 11, '*', 13, '*', 15]
```

Example 4. Replaces every element at an index congruent to 0 (mod 6) with `'A'`; replaces every element at an index congruent to 2 (mod 6) with `'B'`:

```>>> sequencetools.replace_elements(
...     list(range(16)),
...     ([0], 2),
...     (['A', 'B'], 3),
...     )
['A', 1, 'B', 3, 4, 5, 'A', 7, 'B', 9, 10, 11, 'A', 13, 'B', 15]
```

Returns new object of sequence type.