-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintBoard.py
More file actions
18 lines (18 loc) · 1.11 KB
/
printBoard.py
File metadata and controls
18 lines (18 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# prints the board
def printChessBoard(chessboard):
currentRow = 8
# iterates through each row
for row in chessboard:
# prints seperator
print("———————————————————————————————————————————————————")
# prints out the row number, the actual row, separated by a space and a pipe
if currentRow % 2 == 0:
print(f"{currentRow} ⎟ {row[0]} ⎟[|{row[1]}|]⎟ {row[2]} ⎟[|{row[3]}|]⎟ {row[4]} ⎟[|{row[5]}|]⎟ "
f"{row[6]} ⎟[|{row[7]}|]⎟")
else:
print(f"{currentRow} ⎟[|{row[0]}|]⎟ {row[1]} ⎟[|{row[2]}|]⎟ {row[3]} ⎟[|{row[4]}|]⎟ {row[5]} "
f"⎟[|{row[6]}|]⎟ {row[7]} ⎟")
currentRow = currentRow - 1
# bottom of the chessboard, with column names
print("———————————————————————————————————————————————————")
print(" | a | b | c | d | e | f | g | h |")