Assuming that the board is always 9x9, otherwise we can check the size first and return False if needed.

class Solution(object): def isValidSudoku(self, board): # Creating array of strings which represents each row, looking for duplicates in the row rowStringArry = ["","","","","","","","",""] # Check for duplicates in row and columns for col in board: # Keeping count of each number, if it exists, return False colNumCount = [-1,0,0,0,0,0,0,0,0,0] for i in range(0,9): if col[i] == ".": continue if col[i] in rowStringArry[i] or colNumCount[int(col[i])] == 1: return False rowStringArry[i] = ''.join([rowStringArry[i],col[i]]) colNumCount[int(col[i])] += 1 # Check 3x3 blocks col = 0 while col < 9: row = 0 bc1 = board[col] bc2 = board[col+1] bc3 = board[col+2] while row < 7: blockNumCount = [-1,0,0,0,0,0,0,0,0,0] for i in range(row,row+3): if bc1[i].isdigit(): blockNumCount[int(bc1[i])] += 1 if blockNumCount[int(bc1[i])] > 1: return False if bc2[i].isdigit(): blockNumCount[int(bc2[i])] += 1 if blockNumCount[int(bc2[i])] > 1: return False if bc3[i].isdigit(): blockNumCount[int(bc3[i])] += 1 if blockNumCount[int(bc3[i])] > 1: return False row += 3 col += 3 return True