ThomasMarx
New Coder
Python:
board = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
def printBoard(board):
print(board[0] + '|' + board[1] + '|' + board[2])
print('-+-+-')
print(board[3] + '|' + board[4] + '|' + board[5])
print('-+-+-')
print(board[6] + '|' + board[7] + '|' + board[8])
gamenum = 0
odds = ['1', '3', '5', '7', '9']
evens = ['2', '4', '6', '8']
while gamenum < 10:
printBoard(board)
playerx = int(input("what space? "))
if gamenum == 1 or 3 or 5 or 7 or 9:
if board[playerx - 1] == "X" or "O":
print("There is already something here.")
continue
else:
board[playerx - 1] = "X"
printBoard(board)
playery = int(input("what space? "))
if gamenum == 2 or 4 or 6 or 8:
if board[playery - 1] == "X" or "O":
print("There is already something here.")
continue
else:
board[playery - 1] = "O"
my code SHOULD be checking for X or O on the board and then not placing if it detects it, however its detecting x and o everywhere including spaces with integers instead of x or o. Why?
Last edited by a moderator: