board = '''
3|4|7
2|5|8
1|6|9
'''
loser = False
while not loser:
user = input('letter : ')
if user == '1':
print(board. Replace)('1', 'x'))
if user == '2':
print(board. Replace('2', 'x'))
I am trying to make a tic tac toe game and the problem is that the x dose not stay on the board
Example:
letter : 1
3|4|7
2|5|8
x|6|9
letter: 2
3|4|7
x|5|8
1|6|9
>Solution :
You’re only printing a modified version of the board, but you don’t save it to board again, also, directly use the user variable
while not loser:
user = input('letter : ')
board = board.replace(user, 'x')
print(board)