Untitled

mail@pastecode.io avatarunknown
python
a month ago
368 B
6
Indexable
Never
def checkerboard(rows=8, cols=8):
    def helper(r=rows, c=cols, start_white=True):
        WHITE = 'X'
        BLACK = 'O'
        if r==0:
            return
        if start_white:
            print(f'{WHITE}{BLACK}'*(c//2) + WHITE*(c%2))
        else:
            print(f'{BLACK}{WHITE}'*(c//2) + BLACK*(c%2))
        helper(r-1, c, not start_white)

    helper()