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

+7 votes

I got stuck at how to set up the correct expession for While loop so that the player needs to keep clicking until they click in an empty square.

asked in CSC201 Spring 2021 by (1 point)

1 Answer

+3 votes

you want them to keep clicking untill they click a blank square, which is represented by ' ' in the matrix. so the loop should run while ' ' != gameBoard[ ][ ] , with the correct [ ] from the function call.

answered by (1 point)
+1

got it! thanks a lot.

+1

Side note: you could also do

while <choice> == 'X' or <choice> == 'O':

However, != ' ' is simpler.

...