I have a list of countries that I would like to put in an html table.
places = ['Japan','China','North Korea', 'South Korea', 'Vietnam', 'Taiwan', 'Philippines', 'Myanmar']
for now I only have this code which only put <td> and </td> at start and end of every country. I'm having difficulty on how to put <tr> and </tr> for every 3rd line or country it reads. Actually, I don't have an idea how to do it hahaha. (Note in my code I only use print just to show my desired output, I'll use write later)
for x in places:
print('<td>' + x + '</td>')
output:
<td>Japan</td>
<td>China</td>
<td>North Korea</td>
<td>South Korea</td>
<td>Vietnam</td>
<td>Taiwan</td>
<td>Philippines</td>
<td>Myanmar</td>
desired output:
<tr>
<td>Japan</td>
<td>China</td>
<td>North Korea</td>
</tr>
<tr>
<td>South Korea</td>
<td>Vietnam</td>
<td>Taiwan</td>
</tr>
<tr>
<td>Philippines</td>
<td>Myanmar</td>
</tr>
Note: the number of list in places is not fixed. I mean sometimes it may change to something like these places = ['Japan','China'] or just places = ['Japan']