0

I'm pretty new to python(also stack overflow), and as a result I've written myself into a hole. I have a method that figures out a set of coordinates and then passes them through to another class that stores a whole bunch of arrays that hold parameters for a cell.

########### Gate present, No. of enemies, Cleared, CanRun eg. cell10 = ["", "", "", ""]

The array name is broken down into 3 things. First "Cell" which is just so you know what you're referring to. Secondly a number, in this case 1 which means 1 north. Finally another number, 0 in this case which means neither east or west.

This is the code I use to figure out the coords. So now that I have the name of which array I need to take from, I need a way to call that array using the variable name itself.

##Hopefully this formats correctly##

def GetCoords(self, NS = [0,0,0,0,0,0,0,0,0,0], EW = [0,0]):
    NS = 0
    EW = 0
    coords = ""
    # Gets East/West value
    if EastWestWall[1] == 0 and EastWestWall[0] == 0:
        EW = 0
    else:
        if EastWestWall[0] == 1:
            EW = 1
        else:
            if EastWestWall[1] == 1:
                EW = 2
    # Gets North/South value
    NS = NorthSouthWall.index(0)
    coords = "cell" + str(NS) + str(EW)
    print(coords)
    return coords

Thanks in advance :)

0 Answers0