I am putting together a terminal-based RPG where the map is 2D. Presently, I am attempting to find the index of the player’s position, which I will later use to move said player either north/south/east/west (based on the player’s action).
Here is my issue: the only indexes/indices that are stored (or this code works for) are [0][0], [1][1], and [2][2]. The error I receive is with line 20 (ValueError: ‘P’ is not in list). What can I do to adjust/edit my code so that I can find the index of “P” in other spots, such as [0][2] or [2][3]?
enter image description here
As said before, when I move “P” to a position that does not coincide with double digits (i.e. [1][1]), I receive a ValueError in relation to position_y (‘P’ is not in list). Changing the position of “P” to most other positions gives me the same error.
I am using Python 3.11.4 and Visual Studio Code.
Brayden Burleigh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.