FAQ: Minimax - Tic-Tac-Toe

This community-built FAQ covers the “Tic-Tac-Toe” exercise from the lesson “Minimax”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Machine Learning

FAQs on the exercise Tic-Tac-Toe

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Tic-Tac-Toe is a zero-sum game, which means that if both players are playing their best, the game will end in a Tie. However, if you learn how to play tic-tac-toe and master some simple strategies, then you’ll be able to not only play, but to win the majority of the time so try this out.

It is saying that X has not won, when it has

Here is my code:

from tic_tac_toe import *

my_board = [
	["1", "2", "X"],
	["4", "5", "6"],
	["7", "8", "9"]

select_space(my_board, 5, "O")
select_space(my_board, available_moves(my_board)[0], "X")
select_space(my_board, available_moves(my_board)[0], "O")
select_space(my_board, 6, "x")
select_space(my_board, 4, "O")
select_space(my_board, 9, "X")
print(has_won(my_board, "X"))
print(has_won(my_board, "O"))

I see I put a lowercase x by mistake