from typing import Counter


def counter_to_string(counter: Counter, howmany: int = 10) -> str:
    """Turn counter object into a string showing the top howmany items."""
    return "\n".join(
        [
            f"{cnt:5d}: {key}"
            for key, cnt in sorted(counter.items(), key=lambda x: x[1], reverse=True)[
                :howmany
            ]
        ]
    )