
We can use Turtle for fun and can do some show off among our friends, and here I will help you to create a chessboard using python turtle.
First I will put a code and then output, I am telling you just to avoid confusion, enjoy the code.
import turtle sc = turtle.Screen() cb = turtle.Turtle() def draw(): for i in range(4): cb.forward(30) cb.left(90) cb.forward(30) if __name__ == "__main__": sc.setup(400, 600) cb.speed(100) for i in range(8): cb.up() cb.setpos(-100, 30 * i) cb.down() for j in range(8): if (i + j) % 2 == 0: col = 'black' else: col = 'white' cb.fillcolor(col) cb.begin_fill() draw() cb.end_fill() cb.hideturtle() turtle.done()
Output:
