python nested if statements not working
<p>I'm trying to make a game using pygame, and I've set up a couple of functions that I've tested and they work fine. However, in the code below, when I add a print statement to show if my code works, it prints on the first one but not the second.  Any help?</p>

<pre><code>for square in row:
    tile_x = row.index(square)
    # print statement works here
    if self.x_pos - tile_x &gt;= -4 and self.x_pos - tile_x &lt;= 4:
        tile_x = 4 - (self.x_pos - tile_x)
        tile_y = 4 - (self.y_pos - tile_y)
        if square == 'G':
            display('Grass',tile_x,tile_y)
            # print statement doesn't work here
        elif square == 'T':
            display('Tree',tile_x,tile_y)
        elif square == 'B':
            display('Bush',tile_x,tile_y)
        elif square == 'R':
            display('Rock',tile_x,tile_y)
        elif square == 'S':
            display('Stone',tile_x,tile_y)
        # display function has been tested, and it works fine
</code></pre>

<p>I would first have a dict vs all those if statements:</p>

<pre><code>di={'G':'Grass',
    'T':'Tree',
    'B':'Bush',
    'R':'Rock',
    'S':'Stone'}
</code></pre>

<p>Then you can do <code>display(di[square],tile_x,tile_y)</code></p>

python if-statement