有没有办法让Python生成多个if语句?

-2 python if-statement auto-generate

我只需要在每个if语句中为每个数字添加+30.我需要其中的36个,有没有办法让乌龟在陈述或类似的东西上做得更多?我真的被卡住了,手动方式会很疯狂.

例如:

if 0 <= x <=30 and 0 <= y <= 30:
      turtle.drawsstuff

if 30 <= x <=60 and 0 <= y <= 60:

etc.
Run Code Online (Sandbox Code Playgroud)

Joh*_*ohn 5

使用for循环.

for n in range(0, 36 * 30, 30):
    if n <= x <= n + 30 and 0 <= y <= n + 30:
        pass #do something
Run Code Online (Sandbox Code Playgroud)