human
Give me a code to check if any King is unsafe on the Chessboard or not and the other steps required given the following:
Check if any King is unsafe on the Chessboard or not | Function to check if any of the two kings is unsafe or not.
Find the position of both the kings.
Check for all pieces which can attack White King.
Check for Knight.
Check for Pawn.
Check for Rook.
Check for Bishop.
Check for Queen.
Check for King.
Check for all pieces which can attack Black King.
Check for Knight.
Check for Pawn.
Check for Rook.
Check for Bishop.
Check for Queen.
Check for King.
Store all possible moves of the king.
incrementing index values.
checking boundary conditions and character match.
Function to check if Queen can attack the King.
Queen 's moves are a combination  of both the Bishop and the Rook.
Function to check if bishop can attack the king.
Check the lower right diagonal.
Check the lower left diagonal.
Check the upper right diagonal.
Check the upper left diagonal.
Check if.
Check downwards.
Check upwards.
Check right.
Check left.
Check if the knight can attack the king.
All possible moves of the knight.
Incrementing index values.
Checking boundary conditions and character match.
Function to check if pawn can attack the king.
Check for white pawn.
Check for black pawn.
Check if the indices are within the matrix or not.
Checking boundary conditions.
Chessboard instance"
How can the above be solved in Python?
assistant
#Here is code to check if any King is unsafe on the Chessboard or not and the other steps required.
 def checkBoard ( board ) :
	for i in range ( 8 ) :
		for j in range ( 8 ) :
			if board [ i ] [ j ] == ' k ' :
				if lookForn ( board , ' N ' , i , j ) :
					return 1
				if lookForp ( board , ' P ' , i , j ) :
					return 1
				if lookForr ( board , ' R ' , i , j ) :
					return 1
				if lookForb ( board , ' B ' , i , j ) :
					return 1
				if lookForq ( board , ' Q ' , i , j ) :
					return 1
				if lookFork ( board , ' K ' , i , j ) :
					return 1
			if board [ i ] [ j ] == ' K ' :
				if lookForn ( board , ' n ' , i , j ) :
					return 2
				if lookForp ( board , ' p ' , i , j ) :
					return 2
				if lookForr ( board , ' r ' , i , j ) :
					return 2
				if lookForb ( board , ' b ' , i , j ) :
					return 2
				if lookForq ( board , ' q ' , i , j ) :
					return 2
				if lookFork ( board , ' k ' , i , j ) :
					return 2
	return 1
def lookFork ( board , c , i , j ) :
	x = [ - 1 , - 1 , - 1 , 0 , 0 , 1 , 1 , 1 ]
	y = [ - 1 , 0 , 1 , - 1 , 1 , - 1 , 0 , 1 ]
	for k in range ( 8 ) :
		m = i + x [ k ]
		n = j + y [ k ]
		if inBounds ( m , n ) and board [ m ] [ n ] == c :
			return True
	return False
def lookForq ( board , c , i , j ) :
	if lookForb ( board , c , i , j ) or lookForr ( board , c , i , j ) :
		return True
	return False
def lookForb ( board , c , i , j ) :
	k = 0
	while inBounds ( i + + + k , j + k ) :
		if board [ i + k ] [ j + k ] == c :
			return True
		if board [ i + k ] [ j + k ] != ' - ' :
			break
	k = 0
	while inBounds ( i + + + k , j - k ) :
		if board [ i + k ] [ j - k ] == c :
			return True
		if board [ i + k ] [ j - k ] != ' - ' :
			break
	k = 0
	while inBounds ( i - + + k , j + k ) :
		if board [ i - k ] [ j + k ] == c :
			return True
		if board [ i - k ] [ j + k ] != ' - ' :
			break
	k = 0
	while inBounds ( i - + + k , j - k ) :
		if board [ i - k ] [ j - k ] == c :
			return True
		if board [ i - k ] [ j - k ] != ' - ' :
			break
	return False
def lookForr ( board , c , i , j ) :
	k = 0
	while inBounds ( i + + + k , j ) :
		if board [ i + k ] [ j ] == c :
			return...