Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to produce a stack of rows and columns with the addition of X's and O's to produce a game of Tic-tac-toe

. I'm still having trouble of the placement of each of the two functions for a merger. I'm using Python by the way and I just need for anyone to know that if they are experienced with Python.

def BoardX(rows):
	for rows in range(10): #0,1,2,3,4,5,6,7,8,9...20
		if rows%2 == 0: #0,2,4,6,8,10...20
			for columns in range(1,11): #1,2,3,4,5,6,7,8,9,10...20
				if columns%2 == 1:
					if columns != 10:
						print(" ",end=" | "*5)
					else:
						print(" ")	
				else:
					print(" ",end=" ")
					return True
					break


def BoardY(columns):
	for columns in range(5):
		if columns%3 == 0:
			for rows in range(1,6):
				if rows%3 == 1:
					if rows != 5:
						print(" ",end="O")
					else:
						print("")	
				else:
					print("X",end=" ")
    
    


BoardX(1,11)
BoardY(2,10)


What I have tried:

*I tried using an additional value of the "-" with in the first quotations of line 8 and the of line 10 in function BoardX.
Posted
Updated 7-Jan-21 1:00am
Comments
Patrice T 6-Jan-21 20:49pm    
Show result you want and result you get
SithLordDot98 6-Jan-21 20:56pm    
Bye.
Richard MacCutchan 7-Jan-21 5:24am    
It is not easy to figure out what that code is supposed to do. You need to provide more details. I also noticed that although BoardX and BoardY only take a single parameter, you are trying to pass two in each case. So that code will not even compile.

1 solution

Here is a simple function to display an empty board. You can use it as the basis for your program:
Python
def board(rows, columns):
    print('+', end='')
    print('---+' * columns)
    for r in range(rows):
        print('|', end='')
        print('   |'*columns, end='')
        print('')
        print('+', end='')
        print('---+' * columns)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900