So i am making a game involving a 2d array, and i ask the user to input a grid height and width, here is the code that makes the grid
Grid=[['O'for x in range(gridS[0])]for y in range(gridS[1])]
I later change gridS[0] and 1 to gridX and Y
then i try to add players into the grid, again I ask the user how many players (stored in variable opponents) are playing, then add that many players
if opponents>0:
Grid[gridX-1][gridY-2]='P'
if opponents>1:
Grid[0][(gridY-2)]='P'
if opponents>3:
Grid[gridX-1][0]='P'
however, when testing, it comes up with this error:
>>> How many bots do you want to play against?
>>> 10
>>> Please enter a number between 0 and 3
>>> 2
2
Grid[gridX-1][gridY-2]='P'
IndexError: list assignment index out of range