1

After I do

import chess
board = chess.Board()

how can I have a string with the FEN of the position? In other words, how can I extract from board the FEN of the position as a string, with the same output as if I did

a='rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'

?

manlio
  • 18,345
  • 14
  • 76
  • 126
3sm1r
  • 520
  • 4
  • 19

1 Answers1

2

You can use the fen function.

board = chess.Board()
a = board.fen()
merlyn
  • 2,273
  • 1
  • 19
  • 26