import chess.pgn
from chess import Board
pgn = open("somegames.pgn")
game = chess.pgn.read_game(pgn)
board = Board()
for node in game.mainline():
move = node.move
comment = node.comment
print(board.fullmove_number)
print(move)
if comment:
print(comment)
else:
print('(move has no comment)')
board.push(move) # last so that the move numbers are correct, yeah, we could also just count up instead of pushing moves to the board.
print()
Add a code snippet to your website: www.paste.org