Just a seggestion š ... or two if board is going to be a list of numeric strings in order you can also just use range to create your board squars without the list object. that way you dont create two sparate lists each time (board and range). and fstring to help control spacing more. while we are t it lets throw in a new line variable š
For Example:
for square in range(1, 10): # 1-9
nl = '\n' if square%3 == 0 else ''
print(f'| {square} |{nl}', end='')
prints:
| 1 || 2 || 3 |
| 4 || 5 || 6 |
| 7 || 8 || 9 |
As for myself, I like to use Unicode in my console apps
I'll show an example of how I would implement a Board š
using the same 3x3 setup:
top = "āāā¦āā¦āā¦āā¦āā¦āā\n"
between = "ā āā¬āā¬āā¬āā¬āā¬āā£\n"
bottom = "āāā©āā©āā©āā©āā©āā\n"
board = top
rows = 3
for n in range(rows):
board += f'ā {n*3+1} ā¬ {n*3+2} ā¬ {n*3+3} ā£\n'
if n+1 != rows:
board += between
else:
board += bottom
print(board)
prints:
āāā¦āā¦āā¦āā¦āā¦āā
ā 1 ā¬ 2 ā¬ 3 ā£
ā āā¬āā¬āā¬āā¬āā¬āā£
ā 4 ā¬ 5 ā¬ 6 ā£
ā āā¬āā¬āā¬āā¬āā¬āā£
ā 7 ā¬ 8 ā¬ 9 ā£
āāā©āā©āā©āā©āā©āā
many ways to do it. just figured id share š