How to fix Python recursion error when sys module doesn’t work


So I have some code to generate possible board states for a connect four board but resized to a 4×4 board.

def generate_board(board, marker, altMarker, collumnCount):
    global boards
    boardClone = board.copy()
    if check(board, marker):
    if check(board, altMarker):
    if checkTie(board):

    for i in range(0, 4):
        collumnCountClone = collumnCount.copy()
        if collumnCountClone [i] != 0:
            boardClone[collumnCountClone [i] - 1][i] = marker
            collumnCountClone [i] -= 1
        if boardClone not in boards:
        generate_board(boardClone, altMarker, marker, collumnCountClone)
generate_board([[" ", " ", " ", " "], [" ", " ", " ", " "], [" ", " ", " ", " "], [" ", " ", " ", " "]], "B", "R", collumnCount)

But the problem with this is it returns a recursion error. Now I know your probably thinking to just use the sys module and set the recursion amount, but for some reason when I do this the code says it finished but really it doesn’t even print the boards, in fact no print line even comes up, it just finishes the code without doing anything. Does anyone know how to help. I have tried many different things but they don’t work at all?

Source: Python Questions