Code:
Trackback:
Traceback (most recent call last):
File "C:\Users\COMPAQ\Desktop\NoughtsCrosses.py", line 149, in <module>
main ()
File "C:\Users\COMPAQ\Desktop\NoughtsCrosses.py", line 144, in main
move = computer_move(computer, board, human)
File "C:\Users\COMPAQ\Desktop\NoughtsCrosses.py", line 117, in computer_move
board[i] = computer
TypeError: 'str' object does not support item assignment
As you can see for in my tic-tac-toe program, the board[i] = computer line in the computer_move function is the one (if I am reading this right) causing the error. But if I know this right, item assignment is allowed in lists, and I create a local copy of “board” for my function so that I can reassign values and whatnot within the function…
Any input at all would be greatly appreciated. This is my first serious piece of code, so if the function in question looks too mangled
The problem is here:
At the end of the function, you assign
EMPTYtoboard, butEMPTYis an empty string, as defined on line 4. I assume you must have meantboard[i] = EMPTY.