how to check for square condition in sudoku
<p>I am a beginner and wrote a small script for playing sudoku </p>

<p><strong>I was able to check for the row and column conditions but i need little help to check for square condition i.e there should be only one unique digit in a 3x3 square</strong> </p>

<p>Also i would be grateful if anyone would <strong>help me to reduce the size of the conditions and can please explain me how to create a random sudoku board generating random numbers as i have taken a static board</strong> in </p>

<blockquote>
  <p>tf()</p>
</blockquote>

<p>Also <strong>i want to make GUI version</strong> for it so please recommend me a way to do it. </p>

<p>Thanks in advance
following is the code link is available here <a href="https://drive.google.com/file/d/0B0mzB3WBm-8-VzJua1BLakExajQ/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/0B0mzB3WBm-8-VzJua1BLakExajQ/view?usp=sharing</a></p>

<pre><code>board=[[5,7,3,6,9,4,2,1,8],[9,2,4,7,8,1,3,5,'X'],['X',1,6,3,5,'X',7,9,4],[3,8,5,4,2,7,9,6,1],[1,9,2,5,3,6,8,4,7],[4,6,7,9,1,8,5,2,3],[7,3,1,'X',4,5,6,8,'X'],
['X',5,8,1,7,9,4,3,2],[2,4,9,8,6,3,'X',7,5]]#simple sudoku board for testing
def initiator():#print the board and start redirect to the funtion
    for i in range(0,9):
        print str(board[i])+"\n"
    rc_checker()

def find_xs():#find whether there are any remaining spaces to fill
    count = 0
    for i in range(0,9):
        for j in range(0,9):
            if board[i][j] == 'X':
                count+=1
    if count&gt;0:
        return 1
    else:
        for i in range(0,9):
            print str(board[i])+"\n"
            print "Thanks for playing"
def rc_checker():#checks whether inputted row and column are valid 
    if find_xs()==1:
        for i in range(0,9):
            print str(board[i])+"\n"
        print "Give the row and column"
        r = int(input())
        c = int(input())
        if r&lt;10 and c&lt;10:
            r=r-1
            c-=1
            validator(r,c)


def validator(r,c):#validate whether the field is empty and redirects accordingly
    if board[r][c]=='X':
        print "Enter the value"
        val = int(input())
        if val&gt;0 and val &lt;10:
            tf(r,c,val)
            rc_checker() 
    else:
        print "The feild is not empty please try again"
        rc_checker()
def tf(r,c,val):#checking if the inputted value is repeated in corresponding row or column
    i = 0
    r1 = 0
    c1 = 0

    if val!=board[r][i] and val!=board[r][i+1] and val!=board[r][i+2] and val!=board[r][i+3] and val!=board[r][i+4] and val!=board[r][i+5] and val!=board[r][i+6] and val!=board[r][i+7] and val!=board[r][i+8] and val!=board[r1][c] and val!=board[r1+1][c] and val!=board[r1+2][c] and val!=board[r1+3][c] and val!=board[r1+4][c] and val!=board[r1+5][c] and val!=board[r1+6][c] and val!=board[r1+7][c] and val!=board[r1+8][c]:
        print "Value entered is correct"
        board[r][c]=val#value is set
    else:
        print "Invalid value Retry" 
        board[r][c]='X'


def main():#welcome message
    print "Welcome to sudoku game"
    print "Fill all 'X' with valid input"
    initiator()

main()
</code></pre>