(Leetcode) Snakes and Ladders
Type Hinting

You were halfway there! Good job having the type of values accepted and returned in the method docstring. Now, you can use type hints to show in the header of the method what values are accepted and returned, as follows

from typing import List

def snakes_and_ladders(board: List[List[int]]) -&gt; int:


Consistent Spacing

This

for i in range(1,7):


should be this

for i in range(1, 7):


You have good spacing in the rest of your code, but you should stay consistent and apply this spacing everywhere.

The same for this line

stack.append([1,0]) -&gt; stack.append([1, 0])


Magic Numbers

We're coming back to this line again

for i in range(1, 7):


What is 7 supposed to represent? The max number of rows or columns? What if you have to change it later on to apply to smaller/bigger snakes and ladders boards? I would advise using a variable to hold this value, naming it accordingly.

List Comprehension

You use lots of loops with one line in them. Particularly when appending to lists. Luckily, you can add two lists together and it will merge them.

From this

for col in range(cols):
    board_2.append(board[row][col])


to this

board_2 += [board[row][col] for col in range(cols)]


You can do the same for the next loop a couple lines down

From this

for col in range(cols - 1, -1, -1):
    board_2.append(board[row][col])


to this

board_2 += [board[row][col] for col in range(cols - 1, -1, -1)]