python list Index out of range error
- by dman762000
I am working on a python tetris game that my proffessor assigned for the final project of a concepts of programming class. I have got just about everything he wanted to work on it at this point but I am having a slight problem with one part of it. Whenever I start moving pieces left and right I keep getting "index out of range error". This only happens when it is up against a piece. Here are the culprits that are giving me grief.
def clearRight(block=None):
    global board, activeBlock, stackedBlocks
    isClear = True
    if(block == None):
        block = activeBlock
    if(block != None):
        for square in block['squares']:
            row = square[1]
            col = square[0]+1
            if(col >= 0 and stackedBlocks[row][col] !=None):
                isClear=False
    return isClear
def clearLeft(block=None):
    global board, activeBlock, stackedBlocks
    isClear = True
    if(block == None):
        block = activeBlock
    if(block != None):
        for square in block['squares']:
            row = square[1]
            col = square[0]-1
            if(col >= 0 and stackedBlocks[row][col] !=None):
                isClear=False
    return isClear
I am not looking to get anyone to fix it for me, I'm only looking for tips on how to fix it myself.  Thanks in advance for any help that is given.