I made a chess Program.py that is not working fine;
I want to gen the FEN out of the board list that looks like this
board = [
        "R", "N", "B", "K", "Q", "B", "N", "Q", 
        "P", "P", "P", "P", "P", "P", "P", "P",
        " ", " ", " ", " ", " ", " ", " ", " ",
        " ", " ", " ", " ", " ", " ", " ", " ",
        " ", " ", " ", " ", " ", " ", " ", " ",
        " ", " ", " ", " ", " ", " ", " ", " ",
        "p", "p", "p", "p", "p", "p", "p", "p",
        "r", "n", "b", "q", "k", "b", "n", "r"
]
the algorithm I built is shitty and it is just working for the starting case like the list shown up
for the last one, it generates this
rnbkqbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR/
but not for this for example (after 4 moves) it just generates something like this
32/0/PP/2/
board = ['R', ' ', 'B', 'K', 'Q', 'B', ' ', 'R',
         'P', 'P', 'P', ' ', ' ', 'P', 'P', 'P',
         ' ', ' ', 'N', ' ', ' ', 'N', ' ', ' ',
         ' ', ' ', ' ', 'P', 'P', ' ', ' ', ' ',
         ' ', ' ', ' ', 'p', 'p', ' ', ' ', ' ',
         ' ', ' ', 'n', ' ', ' ', 'n', ' ', ' ',
         'p', 'p', 'p', ' ', ' ', 'p', 'p', 'p',
         'r', ' ', 'b', 'k', 'q', 'b', ' ', 'r'
        ]
I want an algorithm that generates the right FEN for the last board and for any other ones, the right one will be
r1bqkb1r/ppp2ppp/2n2n2/3pp3/3PP3/PPP2PPP/R1BKQB1R/
... & and I want the answer in python
 
                        
Try this.
Code
Output