Run length encoding of an input string (Coderbyte 'Run Length' challenge)
You could just make a new list rather than use list.insert and list.append.

indexes.insert(0, 0)
indexes.append(len(s))


indexes = [0] + indexes + [len(s)]

For your "slice string" part, I'd make a function called pairwise. As this is a rather well know recipe in Python.

def pairwise(iterable):
    return (
        (iterable[i], iterable[i+1])
        for i in range(len(iterable) - 1)
    )

You could combine slices and compressed_str into one comprehension. If you do you don't need to use len as indexes[i+1] - indexes[i] is the length of the string.

return "".join(
    f"{b - a}{s[a]}"
    for a, b in pairwise(indexes)
)



def pairwise(iterable):
    return (
        (iterable[i], iterable[i+1])
        for i in range(len(iterable) - 1)
    )


def compress_string(s: str) -&gt; str:
    if s == "":
        return ""

    indexes = [
        i+1
        for i in range(len(s) - 1)
        if s[i+1] != s[i]
    ]
    indexes = [0] + indexes + [len(s)]
    return "".join(
        f"{b - a}{s[a]}"
        for a, b in pairwise(indexes)
    )


Itertools


The pairwise function could be better described using the pairwise recipe.
If you utilize itertools.groupby the challenge is super easy, as it makes slices for you.


def compress_string(s: str) -&gt; str:
    if s == "":
        return ""
    return "".join(
        f"{sum(1 for _ in g)}{k}"
        for k, g in itertools.groupby(s)
    )