This is a section of my code. When i execute the program the output i get is included beneath the code.
currentPos = playerPosition
modifiedCords = freespaceCords
pathList = []
while(True):
adjacentList = []
potentialMoveList = []
currentPos[0] = currentPos[0] - 1
adjacentList.append(currentPos)
print(currentPos)
currentPos[0] = currentPos[0] + 2
adjacentList.append(currentPos)
print(currentPos)
currentPos[0] = currentPos[0] - 1
currentPos[1] = currentPos[1] - 1
adjacentList.append(currentPos)
print(currentPos)
currentPos[1] = currentPos[1] + 2
adjacentList.append(currentPos)
print(currentPos)
currentPos[1] = currentPos[1] - 1
print("")
print(adjacentList)
print("")
output:
[0, 1]
[2, 1]
[1, 0]
[1, 2]
[[1, 1], [1, 1], [1, 1], [1, 1]]
I would like the list of 4 elements to contain the previous four individually printed elements such that:
[ [0,1] , [2,1] , [1,0] , [1,2] ]
Please could someone provide a solution to my problem, explain why their solution works and why my code does not.
Thank you.