Skip to content Skip to sidebar Skip to footer

Checking A Tic Tac Toe Game On Python

I'm working on this project where I check a finished tic tac toe game. The user inputs a combination of x's and o's and periods (max of 3) in each row (there are 3 rows). I have to

Solution 1:

It appears that you misunderstand what the contents of ttt are. Open up the interpreter and try the following:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> tic_tac_toe = []
>>> tic_tac_toe.append(input('Top row: '))
Top row: xxx
>>>
>>> tic_tac_toe
['xxx']
>>> tic_tac_toe.count('x')
0
>>> tic_tac_toe.count('xxx')
1

What happens when you .append('xox')? What does the list look like?


Post a Comment for "Checking A Tic Tac Toe Game On Python"