Printing chessboard with *(asterisk) and .(dot) I have written a program in which user enters total number of conditions (cases) and then that many number of inputs to print chessboard.

For example:

3
21
*
.
12
*.
35
*.*.*
.*.*.
*.*.*


Here is my code:

def main():
    no_of_case = input()
    for i in range(no_of_case): 
        user_input = input()                    # take input

        row = int(str(user_input)[0])
        column = int(str(user_input)[1]) 

        count = 0


        a = "*"
        b = "."

        while True:
            count = count +1 

            if row == 1 and column == 1:
                print "*."
                break

            if row == 1 and column%2 == 0:  
                print (a + b) * (column/2)
                break


            if row == 1 and column%2 != 0:  
                print (a + b) * (column/2) + "*"
                break

            if column == 1 and row%2 == 0:
                print a
                print b 
                if count == row/2:
                    break

            if column == 1 and row%2 != 0:
                print a
                print b

                if count == row/2:
                    print "*"
                    break

            if row != 1 and column !=1:


                if (row%2 == 0) and (column%2== 0): 
                    print (a + b) * (column/2)
                    print (b + a) * (column/2)

                elif (row%2 != 0) and (column%2 == 0):
                    print (a + b) * (column/2)
                    print (b + a) * (column/2)


                elif (row%2 == 0) and (column%2 != 0):
                    print (a + b) * (column/2) + "*"
                    print (b + a) * (column/2) + "."

                elif (row%2 != 0) and (column%2 != 0):  
                    print (a + b) * (column/2) + "*"
                    print (b + a) * (column/2) + "."


                if row%2 == 0 and count == row/2:
                    break

                elif row%2 != 0 and count == row/2:
                    if column%2 == 0:
                        print "*." * (column/2)
                    elif column%2 != 0:
                        print "*." * (column/2) + "*"
                    break







main()


Any suggestion in what way I can improve it?
Your current code limits the number of rows/columns to a single integer. Is this desired behavior?

For clarity sake, I would probably generate the even/odd rows and then print each until you have printed enough rows

Function to specify the input

def get_int_digits(l):
    try:
        inp = input()
    except SyntaxError:
        print "You did not enter anything"
        return 0
    if type(inp) != int:
        print "You did not enter an integer."
        return 0
    if l is not None and len(str(inp)) != l:
        print "You did not enter the correct number of digits."
        print "{} digits expected.".format(l)
        return 0
    return inp


Function to output the "board"

def print_board(row, column):
    even_string = ("*." * (column // 2 + 1)) [0:column]
    odd_string = (".*" * (column // 2 + 1)) [0:column]

    for i in xrange(row):
        print odd_string if i % 2 else even_string 


Driver

if __name__ == __main__:
    cases = get_int_digits(None)
    for i in xrange(cases):
        row_col = get_int_digits(2)
        print_board(row_col // 10, row_col % 10)