tictactoe = [ "X-O", "OX-", "-OX"] # now count the number of X's and O's # on the board and display the result xs = 0 os = 0 for row in tictactoe: for col in row: if col == 'X': xs = xs + 1 elif col == 'O': os = os + 1 print "xs=",xs," os=",os