Tile images in html table using django template syntax

I am trying to tile images with the logic, if there are an even amount of images – tile them (2 per row) and then go on to the next row, if there is only one image – center it, if there are an odd number of images – tile the images but for the last one, center it.

<table style="border-spacing: 0px; margin: 0 auto; width: 100%">
<tbody>
    <tr>{% for item in event.Items %}{% if forloop.counter|divisibleby:2 %}
        <td style="margin-top: 5px;">
        <p style="text-align: center; letter-spacing:0px; font-family:Noto Sans, Helvetica; font-weight:700; font-size:16px; padding: 15px 0;">{{ item.Name }}</p>
        <a target="_blank" rel="nofollow" href="{{ item.ProductURL }}"><img src="{{ item.ImageURL }}" style="width: 250px;" /></a></td>
    </tr>
    <tr>{% endif %}{% endfor %}
    </tr>
</tbody>

I have also been trying to use {% if event.Items|length == 1 %}, {% elif forloop.last and forloop.counter|divisibleby:2 == False %} but have not been able to figure out exactly how to lay everything out. This example below is not tiled – figured using the html table would allow me to do this easier

For Example:

 {% for item in event.Items %}{% if event.Items|length == 1 %}
    <div style="margin:0 auto; text-align: center; clear: both;"><br />
    <p style="display: block;"><a target="_blank" rel="nofollow" href="{{ item.ProductURL }}"><img src="{{ item.ImageURL }}" style="width: 200px; margin: 0 auto; display: block;" />
    </a></p>
<p style="letter-spacing:0px; font-family:Noto Sans, Helvetica; font-weight:700; font-size:16px; text-align: center;">{{ item.Name }}</p>
</div>
   {% elif forloop.last and forloop.counter|divisibleby:2 == False %}
   <div style="clear: both;">def <br>
   <a target="_blank" rel="nofollow" href="{{ item.ProductURL }}"><img src="{{ item.ImageURL }}" style="width: 200px; margin: 0 auto; display: block;" />
<p style="letter-spacing:0px; font-family:Noto Sans, Helvetica; font-weight:700; font-size:16px; text-align: center;">{{ item.Name }}</p>
</div>
{% elif forloop.counter|divisibleby:2 == False %}

<div style="float: left;margin:0 auto; padding-left: 30px;">a
<p><a target="_blank" rel="nofollow" href="{{ item.ProductURL }}"><img src="{{ item.ImageURL }}" style="width: 200px; margin: 0 auto; display: block;" /></a></p>
<p style="letter-spacing:0px; font-family:Noto Sans, Helvetica; font-weight:700; font-size:16px; text-align: center;">{{ item.Name }}</p>
</div>
{% elif forloop.counter|divisibleby:2 %}
<div style="float:right;margin:0 auto; padding-right: 30px;">b
<p><a target="_blank" rel="nofollow" href="{{ item.ProductURL }}"><img src="{{ item.ImageURL }}" style="width: 200px; margin: 0 auto; display: block;" /></a></p>
<p style="letter-spacing:0px; font-family:Noto Sans, Helvetica; font-weight:700; font-size:16px; text-align: center;">{{ item.Name }}</p>
</div>
{% endif %} {% endfor %}

PS – forgive my inline styling!