Function returns true if the move taken is valid else it will return false .
def isSafe ( row : int , col : int , m : List [ List [ int ] ] , n : int , visited : List [ List [ bool ] ] ) -> bool : NEW_LINE INDENT if ( row == - 1 or row == n or col == - 1 or col == n or visited [ row ] [ col ] or m [ row ] [ col ] == 0 ) : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT