How do I print the number of entries assigned to a category?
You'll want to query for the number of entries inside the for loop.

{% for categoryName in craft.categories.group('markets') %}
    {% set numofEntries = craft.entries.section('posts').relatedTo(categoryName).total() %}

    &lt;a href="{{ categoryName.url }}"&gt;{{ categoryName.title }}-{{numofEntries}}&lt;/a&gt;
{% endfor %}