Skip to main content
deleted 169 characters in body; edited tags
Source Link
Mureinik
  • 315.8k
  • 54
  • 395
  • 404

first time poster here. I saw that there was another thread about this, but I'm not yet confident enough in python to get help from that.

I'm wondering why this code does not work.

loop = -10
loop2 = -10
while loop <= 10:
    while loop2 <= 10:
        if current_block:
            block = turtle.Turtle()
            block.shape("square")
            block.color("white")
            block.shapesize(stretch_wid=0.85, stretch_len=0.85)
            block.penup()
            block.goto(loop*20, loop2*20)
        loop2 += 1
    loop += 1

What I want to do is to create a 20x20 grid of squares centered at (0,0). Right now, only a line of squares are created at x-200

Thanks in advance! :)

first time poster here. I saw that there was another thread about this, but I'm not yet confident enough in python to get help from that.

I'm wondering why this code does not work.

loop = -10
loop2 = -10
while loop <= 10:
    while loop2 <= 10:
        if current_block:
            block = turtle.Turtle()
            block.shape("square")
            block.color("white")
            block.shapesize(stretch_wid=0.85, stretch_len=0.85)
            block.penup()
            block.goto(loop*20, loop2*20)
        loop2 += 1
    loop += 1

What I want to do is to create a 20x20 grid of squares centered at (0,0). Right now, only a line of squares are created at x-200

Thanks in advance! :)

I'm wondering why this code does not work.

loop = -10
loop2 = -10
while loop <= 10:
    while loop2 <= 10:
        if current_block:
            block = turtle.Turtle()
            block.shape("square")
            block.color("white")
            block.shapesize(stretch_wid=0.85, stretch_len=0.85)
            block.penup()
            block.goto(loop*20, loop2*20)
        loop2 += 1
    loop += 1

What I want to do is to create a 20x20 grid of squares centered at (0,0). Right now, only a line of squares are created at x-200

Source Link
Rufus
  • 11
  • 1

Python: while loop within a while loop

first time poster here. I saw that there was another thread about this, but I'm not yet confident enough in python to get help from that.

I'm wondering why this code does not work.

loop = -10
loop2 = -10
while loop <= 10:
    while loop2 <= 10:
        if current_block:
            block = turtle.Turtle()
            block.shape("square")
            block.color("white")
            block.shapesize(stretch_wid=0.85, stretch_len=0.85)
            block.penup()
            block.goto(loop*20, loop2*20)
        loop2 += 1
    loop += 1

What I want to do is to create a 20x20 grid of squares centered at (0,0). Right now, only a line of squares are created at x-200

Thanks in advance! :)