I have a simple program:
pos = [1,2]
searched = [
[1,3,4,6],
[2,6,7,8],
[0,1,2,8],
[5,6,9,2]
]
print(searched[pos[0]][pos[1]])
7
Now what I want is some way to get rid off of searched[pos[0]][pos[1]]
and just type something like searched[[pos]]
.
Is there a way to this, or do I have to write out this every time
I have gotten a lot of suggestions, but what I am searching for is a way to do this in one neat line, simplifying everything.
That means that things like using a function, converting to a specific dictionary or even enumerate don't work for me, so for anyone looking at this post later:
.
I suggest usingnp.array(variable)
while defining said variable so you can usevariable[pos]