I am a new programmer and I wanted to start by writing a Tic-tak-Toe program I have more to add but here it is so far.
import random
board = """ 1 | 2 | 3
---+---+---
4 | 5 | 6
---+---+---
7 | 8 | 9 """;
print board
move = raw_input('Where do you want to place your X? ')
board = board.replace(move, "X");
print board
print 'Computer turn:'
comp = random.randint(1, 9)
board = board.replace(comp, "O");
print board
when I run it it shows this error:
Traceback (most recent call last):
File "/private/var/folders/fL/fL1lGxccGCypPBSIUXNGZGpkwIg/-Tmp-/Cleanup At Startup/a-343878441.391.py", line 17, in <module>
board = board.replace(comp, "O");
TypeError: expected a character buffer object
What does this mean, and how would I go about fixing it?