# partition_sequence_by_counts¶

`sequencetools.``partition_sequence_by_counts`(sequence, counts, cyclic=False, overhang=False, reversed_=False)

Partitions sequence by counts.

Example 1. Partitions sequence once by counts without overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [3],
...     cyclic=False,
...     overhang=False,
...     )
[[0, 1, 2]]
```

Example 2. Partitions sequence once by counts without overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(16)),
...     [4, 3],
...     cyclic=False,
...     overhang=False,
...     )
[[0, 1, 2, 3], [4, 5, 6]]
```

Example 3. Partitions sequence cyclically by counts without overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [3],
...     cyclic=True,
...     overhang=False,
...     )
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
```

Example 4. Partitions sequence cyclically by counts without overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(16)),
...     [4, 3],
...     cyclic=True,
...     overhang=False,
...     )
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13]]
```

Example 5. Partitions sequence once by counts with overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
[[0, 1, 2], [3, 4, 5, 6, 7, 8, 9]]
```

Example 6. Partitions sequence once by counts with overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(16)),
...     [4, 3],
...     cyclic=False,
...     overhang=True,
...     )
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10, 11, 12, 13, 14, 15]]
```

Example 7. Partitions sequence cyclically by counts with overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [3],
...     cyclic=True,
...     overhang=True,
...     )
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
```

Example 8. Partitions sequence cyclically by counts with overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(16)),
...     [4, 3],
...     cyclic=True,
...     overhang=True,
...     )
[[0, 1, 2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15]]
```

Example 9. Partitions sequence once by counts and asserts that sequence partitions exactly (with no overhang):

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [2, 3, 5],
...     cyclic=False,
...     overhang=Exact,
...     )
[[0, 1], [2, 3, 4], [5, 6, 7, 8, 9]]
```

Example 10. Partitions sequence cyclically by counts and asserts that sequence partitions exactly (with no overhang):

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [2],
...     cyclic=True,
...     overhang=Exact,
...     )
[[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
```

Example 11. Partitions list:

```>>> sequencetools.partition_sequence_by_counts(
...     list(range(10)),
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
[[0, 1, 2], [3, 4, 5, 6, 7, 8, 9]]
```

Example 12. Partitions tuple:

```>>> sequencetools.partition_sequence_by_counts(
...     tuple(range(10)),
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
[(0, 1, 2), (3, 4, 5, 6, 7, 8, 9)]
```

Example 13. Partitions string:

```>>> sequencetools.partition_sequence_by_counts(
...     'some text',
...     [3],
...     cyclic=False,
...     overhang=True,
...     )
['som', 'e text']
```

Example 14. Reverses cyclic partition with overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
...     [3],
...     cyclic=True,
...     overhang=True,
...     reversed_=True,
...     )
[[0], [1, 2, 3], [4, 5, 6], [7, 8, 9]]
```

Example 15. Reverses cyclic partition without overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
...     [3],
...     cyclic=True,
...     overhang=False,
...     reversed_=True,
...     )
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
```

Example 16. Reverses acyclic partition with overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
...     [3],
...     cyclic=False,
...     overhang=True,
...     reversed_=True,
...     )
[[0, 1, 2, 3, 4, 5, 6], [7, 8, 9]]
```

Example 17. Reverses acyclic partition without overhang:

```>>> sequencetools.partition_sequence_by_counts(
...     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
...     [3],
...     cyclic=False,
...     overhang=False,
...     reversed_=True,
...     )
[[7, 8, 9]]
```

Returns list of objects with type equal to that of sequence.