Removing a class from a list
<p>I am trying to remove classes from a list based on their hp. I am making a large scale battle simulator for a D&amp;D campaign. Its a simple program that makes two lists of classes and pits them against each other.</p>

<p>I am running into a problem when it comes to removing dead fighters. It works fine if one fighter dies in a round, but when multiple die, it goes wonky.</p>

<pre><code>def check_human_deaths():
    for i in range(len(goodguys)):
        if goodguys[i].hp &lt;= 0:
            print('{} has died...'.format(goodguys[i].name))
            goodguys.remove(goodguys[i])
</code></pre>

<p>Removing the dead fighter changes the length of the list, throwing an index error:</p>

<pre><code>IndexError: list index out of range
</code></pre>

<p>I am not to sure how to proceed with removing the dead from the battlefield. Any tips are appreciated. Let me know if I am going about this in a fundamentally wrong way.</p>