Now that ExpressionEngine includes a modulus operator (as of 2.7.1), you can also use that instead of switch
if you prefer.
Here are a couple of examples that both accomplish the same result.
Using modulus to conditionally output all opening and closing html tags:
{exp:channel:entries channel="news"}
{if count % 3 == 1}
<ul class="sub">
{/if}
<li>{title}</li>
{if count % 3 == 0 OR count == total_results}
</ul>
{/if}
{/exp:channel:entries}
...OR....
Put the first opening tag and the final closing tag outside of channel:entries
and use modulus only for conditional closing and re-opening of blocks of html:
<ul class="sub">
{exp:channel:entries channel="news"}
<li>{title}</li>
{if count % 3 == 0}
</ul>
<ul class="sub">
{/if}
{/exp:channel:entries}
</ul>
Either of these examples will work and will always ensure that you have proper tag closure. It's just a matter of preference.
EE Documentation on Modulus Operator