0

My stripped code:

board = [] # 2 dimensional matrix (not showed here)

def build_ships():
    if (
        small_ship(board) == 1
    ):
        # When small_ships returns 1 it doesn't do anything, just ignores my code below
        code_2 clearing board to default
        build_ships()
        return 0


def small_ship(board):
    try:
        code_1 with recursions
    except RecursionError:
        return 1

build_ships()

What am I missing?? I'm blind or missing some important rule here.

Thanks for help

When there's recursion error, it should start over with a clear board, instead it just ignores the code to start over with a clear board and do Nothing at all.

  • What does the recursion look like inside `small_ship.`? As a test just put `raise RecursionError` in that `try` block and it should work right away. If you are just calling `small_ship()` within itself it could be returning `None` when its being called from `builld_ships()` so the if statement will not get triggered. Checkout [this answer](https://stackoverflow.com/a/17778390) as it sounds like it could relate to what is happening here. – kconsiglio Dec 06 '22 at 18:52
  • Please provide enough code so others can better understand or reproduce the problem. – Community Dec 06 '22 at 20:32

0 Answers0