如何在不使用定义的情况下使用乌龟图形和嵌套循环创建棋盘?

问题描述

我正在尝试使用Python的嵌套循环创建棋盘。我很难弄清楚如何用黑色填充特定的盒子以及如何创建64个盒子。到目前为止,我的编码是:

import turtle

t = turtle.Turtle()
t.speed(0)
t.penup() 
t.goto(0,0)
t.pendown() 

for j in range(-150,100,50):
    for i in range(-150,150,50):
        t.penup()
        t.goto(i,j)
        t.pendown()
        t.begin_fill()
        for k in range(4):
            t.forward(50) 
            t.left(90) 
            t.color("black")
            t.end_fill()

for j in range(-100,50):
    for i in range(-100,j)
        t.pendown()
        t.begin_fill()
        for k in range(4):
            t.forward(50) 
            t.left(90) 
            t.end_fill()
            t.hideturtle()

turtle.done()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)