python || easy to understand || with comments || begineer friendly
\nclass Solution:\n    def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        board = [[\'\' for i in range(8)] fo
```\nclass Solution:\n    def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        board = [[\'\' for i in range(8)] for j in range(8)]\n        ans = []\n        \n        # marking queens position on board\n        for queen in queens:\n            board[queen[0]][queen[1]] = \'Q\'\n            \n        # marking kings position on board\n        board[king[0]][king[1]] = \'K\'\n        \n        for queen in queens:\n            # function to check if a queen can target to king on board or not\n            if self.canTarget(queen,king,board):\n                ans.append(queen)\n        return ans\n    \n    \n    \n    def canTarget(self,queen,king,board):\n        q_x,q_y = queen[0],queen[1]\n        \n        # right side\n        for i in range(q_y+1,8):\n            if board[q_x][i] == \'K\':\n                return True\n            elif board[q_x][i] == \'Q\':\n                break\n                \n        # left side\n        for i in range(q_y-1,-1,-1):\n            if board[q_x][i] == \'K\':\n                return True\n            elif board[q_x][i] == \'Q\':\n                break\n                \n        # lower side\n        for i in range(q_x+1,8):\n            if board[i][q_y] == \'K\':\n                return True\n            elif board[i][q_y] == \'Q\':\n                break\n                \n        # upper side\n        for i in range(q_x-1,-1,-1):\n            if board[i][q_y] == \'K\':\n                return True\n            elif board[i][q_y] == \'Q\':\n                break\n                \n        # right down diagonal\n        i,j = q_x+1,q_y+1\n        while i<8 and j<8:\n            if board[i][j] == \'K\':\n                return True\n            elif board[i][j] == \'Q\':\n                break\n            i += 1\n            j += 1\n            \n        # left down diagonal\n        i,j = q_x+1,q_y-1\n        while i<8 and j>=0:\n            if board[i][j] == \'K\':\n                return True\n            elif board[i][j] == \'Q\':\n                break\n            i += 1\n            j -= 1\n            \n        # right up diagonal\n        i,j = q_x-1,q_y+1\n        while i>=0 and j<8:\n            if board[i][j] == \'K\':\n                return True\n            elif board[i][j] == \'Q\':\n                break\n            i -= 1\n            j += 1\n            \n        # left up diagonal\n        i,j = q_x-1,q_y-1\n        while i>=0 and j>=0:\n            if board[i][j] == \'K\':\n                return True\n            elif board[i][j] == \'Q\':\n                break\n            i -= 1\n            j -= 1\n            \n        # otherwise\n        return False\n```
['Python', 'Python3']