Skip to content

Bug: Program crashes when board is full in Tic Tac Toe game #297

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
snehauppula opened this issue Apr 26, 2025 · 4 comments
Open

Bug: Program crashes when board is full in Tic Tac Toe game #297

snehauppula opened this issue Apr 26, 2025 · 4 comments

Comments

@snehauppula
Copy link

After the board is filled in the Tic Tac Toe game, the program crashes with an error:

TypeError: list indices must be integers or slices, not NoneType
Cause:
The compMove() function returns None when no moves are left, but the program tries to insert at board[None].

Suggested Solution:
Before calling insertLetter("O", move), check if move is None and handle it as a tie.

Example:
if move == 0 or move is None:
print("Tie game")
else:
insertLetter("O", move)
print(f"Computer placed O on position {move}")
printBoard(board)

Additional Suggestion:
In compMove(), add a check:
if len(possibleMoves) == 0:
return None

Happy to work on fixing this if you would like! 🚀

Apache-R added a commit to Apache-R/Python-Projects that referenced this issue May 23, 2025
@koilakuntlamunnaf
Copy link

Hi @snehauppula, I would like to check and resolve this issue. Can I take up this issue?

@snehauppula
Copy link
Author

snehauppula commented Jun 8, 2025

Yeah.I will be more happy if you do so

@Neha01010
Copy link

Hi. @snehauppula is the issue still open? I would like to work on it if it is still available

@snehauppula
Copy link
Author

Yeah.I will be more happy if you do so

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants