Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+8 votes

I'm trying to finish the playOneRound() function, but I am confused which method we are supposed to use. I remember talking about that in order to add things into lists we could either use .insert() or .append(). I thought it wouldn't be the .append() since that adds to the end of a list and we're not trying to do that. So I tried to insert the currentPlayerShape in the row, col that is returned from the getUserRowColumnChoice() function. That doesn't work because it says the insert method can't run with a tuple. What else can I try to get this part of the code working?

asked in CSC201 Spring 2021 by (1 point)

2 Answers

+5 votes
 
Best answer

The original gameGrid looks like this

            [[' ',' ',' '],
            [' ',' ',' '],
            [' ',' ',' ']]

You 're right about the append method. We shouldn't use it because we do not want to add more elements to the end of the list.
We do not use insert either because we do not want to add more elements.
What we want to do is to change the value of the element of the list. Specifically, change the blank element to 'X' or 'O'. In order to do so, you just have to do something like this

gameGrid[index][index] = the value what want to change to ('X' or 'O')
answered by (1 point)
selected by
+3 votes

I just set gameGrid[row][col] equal to 'X' or 'O'. There might be a better way, but that's what worked for me!

answered by (1 point)
...